human
python regular expression to remove repeated words
assistant
Here is some code to remove duplicate words from a string `text` using regex

text = re.sub('\\b(\\w+)( \\1\\b)+', '\\1', text)

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