import re s = "CEEEETTEEEEGGGCCBCTTBHHHHHCCEEEEEEEEETTEETT"pattern = r"(?<=[CEHBGITS])([CEHBGITS])\1*"print(re.sub(pattern, " \g<0>", s))
Standard input is empty
C EEEE TT EEEE GGG CC B C TT B HHHHH CC EEEEEEEEE TT EE TT
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!