Search code examples
regexgrepstring-parsing

How to match generic string = generic string


Let's say I have this file:

AND 1=1
AND fejo = fejo
AND 4=5
AND 423=523

I want to match the lines which what is at the left of the = is the same as what there is at the right of the = symbol, so, it has to match the following lines:

AND 1=1
AND fejo = fejo

Solution

  • I found another pretty simple solution without having to make a huge mess:

    AND (\w+)\s*=\s*\1