regexgrepemacs23

regular expression with the same element twice without knowing it


I've plenty fill and want to find all of them which are like this:

A = A + B

So I wanna use a regular expression using M + x rgrep. and was thinking to something like that: ([A-Za-z][A-Za-z0-9]*) = () + [A-Za-z][A-Za-z0-9]* where () create a group which can be used latter.

Their is a way to make a regular expression where two item must be the same but without knowing the form of them?


Solution

  • I think you want something like this,

    ([A-Za-z][A-Za-z0-9]*) = \1 \+ [A-Za-z][A-Za-z0-9]*
    

    DEMO