I have a file with the swift data in the below format that needs to be split into multiple lines using regular expression in python. Original file:
ID Information
1 :20:Test1 :25:test2:28C:test3
Desired Output:
ID Information
1 :20:Test1
1 :25:test2
1 :28C:test3
Using Notepad++ I am able to break the 'Information'column into multiple lines using
Find: ^:[0-9]{2}:|\s:[0-9]{2}:|\s:[0-9]{2}[A-Za-z]{1}:
Replace : \n$0
Need to replicate the same using python. So far i tried the below code but the result does not contain the pattern. It is splitting after the pattern match:
import re
s = ':20:Test1 :25:test2:28C:test3'
l = re.compile('^:[0-9]{2}:|\s:[0-9]{2}:|\s:[0-9]{2}[A-Za-z]{1}:').split(s)
Result: ['', 'Test1 ', 'test2 ', 'test3']
The result should also contain the regex pattern while splitting the string.