Test, validate and match regular expressions
Matches consecutive repeated words in text by capturing a word with (\w+) and using backreference \1 to match the identical word again after whitespace. Word boundaries ensure full-word matches, preventing partial overlaps. Commonly used to detect accidental duplicate words like 'the the' in proofreading, text cleanup, and content validation. The g flag finds all occurrences while m enables multiline matching.