[COFF] Requesting thoughts on extended regular expressions in grep.

Grant Taylor via COFF coff at tuhs.org
Sat Mar 4 05:06:17 AEST 2023


Thank you all for very interesting and engaging comments & threads to 
chase / pull / untangle.

I'd like to expand / refine my original question a little bit.

On 3/2/23 11:54 AM, Grant Taylor via COFF wrote:
> I'd like some thoughts ~> input on extended regular expressions used 
> with grep, specifically GNU grep -e / egrep.

While some reading of the references that Clem provided I came across 
multiple indications that back-references can be problematic from a 
performance stand point.

So I'd like to know if all back-references are problematic, or if very 
specific back-references are okay.

Suppose I have the following two lines:

    aaa aaa
    aaa bbb

Does the following RE w/ back-reference introduce a big performance penalty?

    (aaa|bbb) \1

As in:

    % echo "aaa aaa" | egrep "(aaa|bbb) \1"
    aaa aaa

I can easily see how a back reference to something that is not a fixed 
length can become a rabbit hole.  But I'm wondering if a back-reference 
to -- what I think is called -- an alternation (with length fixed in the 
RE) is a performance hit or not.

Now to read and reply to the many good comments that people have shared. 
  :-)



-- 
Grant. . . .
unix || die

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4017 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://www.tuhs.org/pipermail/coff/attachments/20230303/8af3e274/attachment-0001.p7s>


More information about the COFF mailing list