I have a string 1 blahblahblah 2 sdsdsdsdsd 3 uuuuuu 4 eeee 5 abcdef
I would like to output
1 blahblahblah
2 sdsdsdsdsd
3 uuuuuu
4 eeee
5 abcdef
I have tried to add \n before every number by using re.split but it didn’t work
re.split(' (?=[1-9]:)', line)
The following works just fine:
Demo:
The expression
(\d+)matches 1 or more digits, and I replace that with a newline followed by the matched digits (via the capturing group).