import re
regex = re.compile(r".*SFR$", flags=re.MULTILINE)
test_str = ("1468 SFR-PHOTO_000-€\n"
"CAP- 1235 SFR1-\n"
"C-Z01434-SFR- PHOTO 000-\n"
"C-Z01468-SFR\n"
"SN- 1468 --SFR•+-CE•-•Request-for-approval\n"
"PAC-X0123 SFR-\n"
"B-00123•- Invoice for ABC\n"
"C-925303-SFR-\n"
"C-L25254-SFR\n"
"C-LP1122 SFR-\n"
"A-123456 SFR\n"
"A-789654 SFR\n"
"A-Q12345-SFR\n"
"DDD-BN4455_SFR\n"
"WWW 78955_SFR\n"
"V 963852-SFR")
matches = regex.finditer(test_str)
for match_num, match in enumerate(matches, start=1):
print(f"Match {match_num} 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