<human>:  regex for repeating words in a string in Python
<bot>: Here is some code to regex for repeating words in a string `s`

re.sub('(?<!\\S)((\\S+)(?:\\s+\\2))(?:\\s+\\2)+(?!\\S)', '\\1', s)

#Warning: this code generation is experimental. Please inspect the code for any bugs before executing.