Andreas Schwab

  *
Why?  There are no subexpression in your regexps.

My bad. I really should have looked twice on what the manual says on 
BASH_REMATCH and checked up on what subexpressions is supposed to result.
I thought they were a synonym for multiple results returned by a global flag, 
thinking that bash's '=~' had a permanent global flag set (hence why i was 
comparing it with grep -E) which seems like something that isn't currently 
implemented.

Chet Ramey

  *
Bash doesn't provide its own implementation of EREs: it uses whatever libc
supplies. I assume that's different from whatever `grep -E' uses.

Greg Wooledge

  *
If you want [a-z] to work like ASCII does, you'll need to use LC_CTYPE=C.

If you want to match lowercase letters in your current locale, you
should use [[:lower:]] instead.

Thank you for that though. Very interesting to say the least to see the get an 
idea in differences on ERE's, and at the very least I'll make sure to set my  
LC_CTYPE to C from now on..

________________________________
From: Chet Ramey <chet.ra...@case.edu>
Sent: Tuesday, May 20, 2025 9:59 PM
To: FunnyMan Computer <funnymancompu...@outlook.com>; bug-bash@gnu.org 
<bug-bash@gnu.org>
Cc: chet.ra...@case.edu <chet.ra...@case.edu>
Subject: Re: Difference in POSIX regular expression for bash's '=~' operator 
and POSIXLY_CORRECT grep -E

On 5/20/25 3:08 PM, FunnyMan Computer wrote:

> Bash Version: 5.2
> Patch Level: 37
> Release Status: release
>


> Description:
>       Bash's '=~' extended POSIX regex seems to behave very different to the 
> way grep's -E flag seems to deal with regular expressions.

Bash doesn't provide its own implementation of EREs: it uses whatever libc
supplies. I assume that's different from whatever `grep -E' uses.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    c...@case.edu    http://tiswww.cwru.edu/~chet/

Reply via email to