import rep = re.compile(r'\[\d+\]')test_str = "[1]first[2]second[3]third"print([x for x in p.split(test_str) if x])
Standard input is empty
['first', 'second', 'third']
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!