Is there a way to compare regex backlinks?

I have the following example expression that I pass egrep over a list of words:

^([a-z])lu([a-z])\2er$

I would like to further indicate that the contents of \ 1 and \ 2 must be different, for example. it will be bluff but not blubber. Is there a way to build this in the expression itself (so that I can get my results directly from egrep or something like that), or am I sticking to this in some real language with regular expression support and manually checking that none of my groups is not the same?

+3
source share
2 answers

- . . Sed, , , .

+2

lookahead (?!\1) . :

([a-z])lu(?!\1)([a-z])\2er

"bluffer", "blubber". , .

+3

Source: https://habr.com/ru/post/1786770/


All Articles