import re
regex = re.compile(r"CGK / WIII")
test_str = ("LOCATION REFERENCE UPLIFT TICKET TAIL FLIGHT AIRCRAFT DESCRIPTION UOM QUANTITY UNIT EXTENDED\n"
" NUMBER DATE NUMBER NUMBER NUMBER TYPE\n"
" SHIPPED PRICE PRICE\n\n"
"CGK / WIII 1208975-24101 24-MAR-21 08312411 VN-A633 VJ2432 Airbus 321 JET FUEL\n"
" USG -1,945.36 2.29783 (4,470.11)\n"
" 1208975-24101 Total\n"
" -1,945.36 (4,470.11)\n"
"CGK / WIII 1208976-24101 26-MAR-21 08517889 VN-A633 VJ2432 Airbus 321 JET FUEL\n"
" USG -2,802.86 2.29783 (6,440.51)\n"
" 1208976-24101 Total\n"
" -2,802.86 (6,440.51)\n"
"CGK / WIII 1208979-24101 28-MAR-21 08705413 VN-A633 VJ2432 Airbus 321 JET FUEL\n"
" USG -2,900.08 2.29783 (6,663.89)\n"
" 1208979-24101 Total\n"
" -2,900.08 (6,663.89)\n"
"CGK / WIII Total\n"
" -7,648.31 (17,574.51)\n"
"Grand Total\n"
" -7,648.31 (17,574.51)")
match = regex.search(test_str)
if match:
print(f"Match was found at {match.start()}-{match.end()}: {match.group()}")
for group_num, group in enumerate(match.groups(), start=1):
print(f"Group {group_num} found at {match.start(group_num)}-{match.end(group_num)}: {group}")
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Python, please visit: https://docs.python.org/3/library/re.html