import remy_str = 'my example example string contains example some text'my_str = re.sub(r'\b(example)(?:\s+\1)+\b', r'\1', my_str)print(my_str)
Standard input is empty
my example string contains example some text
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!