import rep = re.compile(r'(?:[^_:]|(?<!_)_(?!_))+')s = "GT__abc23_1231:TF__XYZ451"print(p.findall(s))
Standard input is empty
['GT', 'abc23_1231', 'TF', 'XYZ451']
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!