Find duplicate variable declaration Regex

I’m looking to build a regex that will find duplicate string/variables. An example of the input as follows:

     <SymbolVar name="DATABASE_NAME" value="DB1"/>
     <SymbolVar name="DATABASE_NAME" value="DB2"/>
     <SymbolVar name="PORT" value="12345"/>
     <SymbolVar name="SERVER_NAME" value="Server1"/>
     <SymbolVar name="SERVER_NAME" value="Server2"/>

The returned find should match “DATABASE_NAME” and “SERVER_NAME” present both twice.

My first attempt as follows, doesn’t quite cut it

(?m)<SymbolVar name=”(\S+).\R(?s).?\K\1

Read more here: Source link