Regular Expressions 101

Community Patterns

Remove all duplicate words

0

Regular Expression
ECMAScript (JavaScript)

/
\b(\w+)(?!\s+\1\b)\b
/
gmi

Description

Removes all words that are NOT followed by a space, followed by the same word

Submitted by anonymous - 2 years ago (Last modified 2 years ago)