Optional Chaining \b([.a-zA-Z]+)\s+?&&\s+?\1\. This should find instances such as: test && test.thing And test.data && test.data.other But not: test && test test && other