import retext = "aaa, aa, a,broom, school...boo, gool, ooow."print( re.sub(r'\b(([a-zA-Z])\2+)\b|([a-zA-Z])\3+', r'\1\3', text) )
Standard input is empty
aaa, aa, a,brom, schol...bo, gol, ow.
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!