Finding repeating words in a document

Q

How to find repeating words in a text document with a regular expression?

An example text document is listed below:

✍: FYIcenter.com

A

The regular expression to find repeating words in a text document can be written as: Note that:

\b(\w+)      - identifies a word
\s+(\g1)\b   - the same word repeated again using backreference

Click the button to test this regular expression here online:

2013-02-03, 1904👍, 0💬