new_state_line = """
08 FEB 20 HME FEB08 WEBLW HGH @10:08 359.00
08 FEB 20 HME FEB08 WEBLW HGH @10:10 550.00 912.00
18 FEB 20 JJ MAYOR WINNER 34.06 875.94
28 FEB 20 ADVICE CONFIRMS RBC280W5F82WW SOMETING GIVEN 3,459.00 4,333.94
02 MAR 20 STAGECOACH SHOW STOP 59.50 4,277.44
"""
I wrote a following regex pattern:
>>pattern = r'(\d{2}\s[A-Z]{3}\s\d{2}) (.+)\s([0-9,]+\.[0-9]+)\s*(([0-9,]+\.[0-9]+)|$)'<<
for ech_line in new_state_line.split('\n'):
reg = re.search(pattern, ech_line.upper())
if(reg):
print(reg.group(3), reg.group(4))
Which gives output
359.00
912.00
875.94
4,333.94
4,277.44
Expecting to see output similar to:
359.00 None\''
550.00 912.00
34.06 875.94
3,459.00 4,333.94
59.50 4,277.44
This is in Python. Can someone help in writing the regex pattern? Coz I'm quite lost here.