Regex for repeated word

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

Options
Matches

Examples

Note

The backreference \1 matches whatever the group captured, so any word typed twice is caught.

Matches in the example

  • "is is"
  • "the the"

Token by token

  1. \b a word boundary
  2. ( a capturing group
  3. \w+ a word character (letter, digit or _), one or more times, as many as possible
  4. ) end of group
  5. \s+ a whitespace character, one or more times, as many as possible
  6. \1 the same text group 1 matched
  7. \b a word boundary

Other patterns