bug-grep
[Top][All Lists]
Advanced

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

Re: lowercase letters for binaries


From: Benno Schulenberg
Subject: Re: lowercase letters for binaries
Date: Mon, 07 Nov 2005 21:40:49 +0100
User-agent: KMail/1.8.3

Andreas Schwab wrote:
> Benno Schulenberg <address@hidden> writes:
> > Hmm...  I'm not sure that backreferences are working correctly.
> > Shouldn't
> >
> >   echo "cbaa" | egrep '(aa)cb|cb\1'
> >
> > give output?
>
> Since (aa) does not match anything, what should \1 match?  Note
> that a back-reference does not repeat the matching of the
> referenced subexpression, but only matches the exact string that
> was previously matched.

Ah.  That "previously matched" is what I hadn't understood -- and 
this is precisely what point 13 tries to explain.  So maybe the 
following is a better text for 'info grep usage':

13. Why is this back-reference failing?

        echo "ba" | egrep '(a)\1|b\1'

    This gives no output, because the first alternate '(a)\1' does
    not match, as there is no "aa" in the input, so the '\1' in the
    second alternate has nothing to refer back to, meaning it will
    never match anything.  (The second alternate in this example
    can only match if the first alternate has matched -- making
    the second one superfluous.)

Benno




reply via email to

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