import retext = "test 10 20 middle 30 - 40 mm"print( re.split(r'(?<=\d)\s+(?:-\s+)?(?=\d)', text) )
Standard input is empty
['test 10', '20 middle 30', '40 mm']
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!