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