[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: why are \d and \D not implemented but don't throw errors in regex?

From: Linda Walsh
Subject: Re: why are \d and \D not implemented but don't throw errors in regex?
Date: Tue, 10 Dec 2013 12:28:03 -0800
User-agent: Thunderbird

On 12/7/2013 3:33 PM, Peter Cordes wrote:
 I agree your complaint seems valid, but it's the behaviour of the
regex engine built into GNU libc (in this case).  Bash on other
platforms would use the regex engine in their system libc.  (Unless
I'm mistaken in my assumption that bash doesn't have its own regex
Maybe Bash could follow the example of GNU grep and add the defacto
perl standard as listed here: http://en.wikipedia.org/wiki/Regular_expression

There, it lists the simple and extended posix, and the third standard being
perl's RE:

   "The Perl standard is still evolving in Perl 6, but the current
    set of symbols and syntax has become a de facto standard.

    Largely because of its expressive power, many other utilities and
    programming languages have adopted syntax similar to Perl's — for example,
    Java, JavaScript, Python, Ruby, Microsoft's .NET Framework, and the W3C's
    XML Schema all use regular expression syntax similar to Perl's. Some
    languages and tools such as Boost and PHP support multiple regular
    expression flavors. Perl-derivative regular expression implementations are
    not identical and usually implement a subset of features found in Perl 5.0,
    released in 1994. Perl sometimes does incorporate features initially found
    in other languages, for example, Perl 5.10 implements syntactic extensions
    originally developed in PCRE and Python

An option:

shopt -s regex=(basic|[extended]|pcre)
where 'extended' is the default would be a
great extension.

Likely bash could just copy the re-engine selection and use-code from

Certainly wouldn't violate posix to have such an option.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]