[Bug regex/14301] Regular expression wrong match with a number of groups
valery_reznic at yahoo dot com
sourceware-bugzilla@sourceware.org
Wed Jun 27 08:51:00 GMT 2012
http://sourceware.org/bugzilla/show_bug.cgi?id=14301
--- Comment #4 from Valery <valery_reznic at yahoo dot com> 2012-06-27 08:50:54 UTC ---
(In reply to comment #3)
> (In reply to comment #2)
> > (In reply to comment #1)
> > > (4[0-9]{12}) matches 4123456789012.
> >
> > So what?
> > Regular expression required leading and trailing space to be present for match.
>
> I don't think so. "|" does not bind this way. a[b]|c|d[e] is equivalent to
> (ab)|c|(de), not (a)(b|c|d)(e).
>
> > Also please note, that in case 3 and 4 regular expressions are essentially the
> > same - only (4[0-9]{15}) and (4[0-9]{12}) that connected with OR swapped.
>
> This also explains the difference when swapping the parenthesized constructs.
Got it! Leading space was part only of the first ( ) group, trailing space
was part only of the last ( ) group
For some reason I though that '|' has higher priority than concatenation.
One more pair of the () fixed the problem.
'[ ]((4[0-9]{15})|(4[0-9]{12})|(AAA))[ ]'
Thank you very much for the explanation. I didn't believe how stupid I was.
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the Glibc-bugs
mailing list