fork download
  1. import re
  2. my_str = 'my example example string contains example some text'
  3. my_str = re.sub(r'\b(example)(?:\s+\1)+\b', r'\1', my_str)
  4. print(my_str)
Success #stdin #stdout 0s 23352KB
stdin
Standard input is empty
stdout
my example string contains example some text