import re my_str = '610640: 168 hours 610835: till next day 14:00 617041: 168 hours 611486:720 hours' match = re.split(r'\s+(?=\d{6}:)', my_str) print(match) for item in match: print(item)
Standard input is empty
['610640: 168 hours', '610835: till next day 14:00', '617041: 168 hours', '611486:720 hours'] 610640: 168 hours 610835: till next day 14:00 617041: 168 hours 611486:720 hours