Regex for repeated word
/\b(\w+)\s+\1\b/gi
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
\ba word boundary(a capturing group\w+a word character (letter, digit or _), one or more times, as many as possible)end of group\s+a whitespace character, one or more times, as many as possible\1the same text group 1 matched\ba word boundary
Other patterns
- Email address
- URL
- IPv4 address
- UUID
- Hex color
- Date (YYYY-MM-DD)
- Time (24-hour)
- US phone number
- Phone number (E.164)
- US ZIP code
- Credit card number
- URL slug
- Username
- Strong password
- HTML tag
- Semantic version
- MAC address
- JSON Web Token
- Hashtag
- @mention
- Number
- Leading and trailing whitespace
- Repeated word
- Blank lines
- Markdown link
- Quoted string
- Domain name
- File extension
- Base64
- Trailing comma