Text Processingflags: gi

Duplicate Word

Detects consecutive duplicate words using a backreference.

Try it in RegexPro

Pattern

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

Raw source: \b(\w+)\s+\1\b

How it works

`\b(\w+)\b` captures a word. `\s+\1\b` matches whitespace followed by the same word (backreference `\1`). Case-insensitive.

Examples

Input

the the cat sat on the the mat

Matches

  • the the
  • the the

Input

no duplicates here

No match

Common use cases

  • Proofreading
  • Content editors
  • Writing-quality linters

Related concepts