-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
  • 795
  • 2
  • 9
  • 14

1 Answers1

0

Try matching .* in between occurrences:

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

Demo

Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360