bug-grep
[Top][All Lists]
Advanced

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

bug#36148: inconsistent behaviour with anchored regex containing back-re


From: g1pi
Subject: bug#36148: inconsistent behaviour with anchored regex containing back-references
Date: Sun, 9 Jun 2019 10:00:24 +0200
User-agent: NeoMutt/20170113 (1.7.2)

There seems to be a problem with beginning/end-of-line anchors in regex
containing back-references:

$ grep -V | head -1
grep (GNU grep) 3.1

$ cat words
ana
deed
ill
stats

Using -x to match whole line works:

$ egrep -x '(.?)(.?).?\2\1' words 
ana
deed
stats

Using explicit anchors emits false positives:

$ egrep   '^(.?)(.?).?\2\1$' words 
ana
deed
ill     <<<
stats

On the other hand, colouring the output shows that grep somewhat knows its
mistake:

$ egrep --color '^(.?)(.?).?\2\1$' words 
ana     (coloured)
deed    (coloured)
ill
stats   (coloured)






reply via email to

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