bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: [grep 2.5.1] odd output for some patterns combining backreference, a


From: Ralf Wildenhues
Subject: Re: [grep 2.5.1] odd output for some patterns combining backreference, alternation, and repetition
Date: Tue, 2 Oct 2007 20:42:12 +0200
User-agent: Mutt/1.5.13 (2006-08-11)

Hello Bauke, Alex,

* Bauke Jan Douma wrote on Tue, Oct 02, 2007 at 12:10:20AM CEST:
> Alex Lamey wrote on 30-09-07 22:03:
>>
>>> $ echo 88-88 | egrep -o '([0-9])([0-9])-(\1|\2){3}'
>>> 88-88
>>     !
[...]
> Not a bug -- assuming the ! is and envisualization of your surprise.
>
> The [0-9] means just one digit in that range.  So each of these
> two constructs matches at most just one digit.  Hence \1 can only be
> a reference to at most one digit.  Same for \2.  And hence the same
> for \1|\2.
> Therefore {1} gives you just one digit on the right side of the dash,
> {2} gives you 2, and anything else just doesn't match, because you're
> asking too many: {n} means /exctly/ n matches.

Maybe I'm being dense here, but the above example (just like the others
that Alex annotated) asks for three digits after the hyphen, but egrep
actually matches with two.  Looks like a bug to me, no?

FWIW, I can't reproduce the above with version 2.5.1 on GNU/Linux.

Cheers,
Ralf




reply via email to

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