-1

I need a regexp, which matches duplicate words. I try this:

\b(\w+)\s+\1\b

This good, but is matches only consecutive duplicate words.

How can i matches not only consecutive duplicate words?

Lay András
  • 693
  • 1
  • 6
  • 13

1 Answers1

0

Try matching .* in between occurrences:

\b(\w+).*\1\b

Demo

Tim Biegeleisen
  • 451,927
  • 24
  • 239
  • 318