import refor s in ("classss", "oooooops", "foooobooo"): print(re.sub(r'(\w)\1\1+', r'\1\1', s))
Standard input is empty
class oops fooboo
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!