I have the following sample text:
Performed by:
ID NUMBER:
XSOR-160491"
15632894,136259874,"TEXT:
Name: John Age:80
[Lots of text spanning multiple lines with special characters, new lines and whitespaces]
XSOR-160491"
78452156,784569851,"TEXT:
Name: Sally Age:31
[Lots of text spanning multiple lines with special characters, new lines and whitespaces]
ID NUMBER:
01236589,489456156878,"TEXT:
Name: Suraj Age:56
[Lots of text spanning multiple lines with special characters, new lines and whitespaces]
00123795,,"TEXT:
Name: Shiloh Age:12
[Lots of text spanning multiple lines with special characters, new lines and whitespaces]
And I'm trying to split it to the left of:
ID NUMBER:
XSOR-160491"
15632894,136259874,"TEXT:
where all the bolded text is optional (not present in every instance).
I created the following regex expression but it consumes the information I want to keep and doesn't necessarily account for all the bolded optional text.
re.split(r"[0-9]+,[0-9]+?,\"TEXT", test))
I tried adding lookahead with ?=:
re.split(r"?=([0-9]+,[0-9]+?,\"TEXT)", test))
But that didn't seem to work. Any help is greatly appreciated!
Edit: Expected output is as follows:
ID NUMBER:
XSOR-160491"
15632894,136259874,"TEXT:
Name: John Age:80
...
XSOR-160491"
78452156,784569851,"TEXT:
Name: Sally Age:31
...
ID NUMBER:
01236589,489456156878,"TEXT:
Name: Suraj Age:56
...
00123795,,"TEXT:
Name: Shiloh Age:12
...