import re
regex = re.compile(r"(?:\d*\.)?\d+$", flags=re.MULTILINE)
test_str = ("\n"
"22/09/2015 11:05:41 | Dispense complete for COTTON, final dispense weight was 0.0262\n\n\n"
"22/09/2015 11:08:02 | Dispense complete for COTTON, final dispense weight was 0.0264\n\n\n"
"22/09/2015 11:10:08 | Dispense complete for COTTON, final dispense weight was 0.0229\n\n\n"
"22/09/2015 11:12:03 | Dispense complete for COTTON, final dispense weight was 0.0188\n\n\n"
"22/09/2015 11:14:22 | Dispense complete for COTTON, final dispense weight was 0.0292\n\n\n"
"22/09/2015 11:16:48 | Dispense complete for COTTON, final dispense weight was 0.0245\n\n\n"
"22/09/2015 11:18:37 | Dispense complete for COTTON, final dispense weight was 0.0243\n\n\n"
"22/09/2015 11:20:56 | Dispense complete for COTTON, final dispense weight was 0.0261\n\n\n"
"22/09/2015 11:22:53 | Dispense complete for COTTON, final dispense weight was 0.0228\n\n\n"
"22/09/2015 11:24:43 | Dispense complete for COTTON, final dispense weight was 0.0204\n\n\n"
"22/09/2015 11:26:38 | Dispense complete for COTTON, final dispense weight was 0.0223\n\n\n"
"22/09/2015 11:28:29 | Dispense complete for COTTON, final dispense weight was 0.0257\n\n\n"
"22/09/2015 11:30:20 | Dispense complete for COTTON, final dispense weight was 0.0371\n\n\n"
"22/09/2015 11:32:14 | Dispense complete for COTTON, final dispense weight was 0.0376\n\n\n"
"22/09/2015 11:36:18 | Dispense complete for COTTON, final dispense weight was 0.0222\n\n\n"
"22/09/2015 11:39:28 | Dispense complete for COTTON, final dispense weight was 0.0234\n\n\n"
"22/09/2015 11:41:23 | Dispense complete for COTTON, final dispense weight was 0.0255\n\n\n"
"22/09/2015 11:43:24 | Dispense complete for COTTON, final dispense weight was 0.0242\n\n\n"
"22/09/2015 11:46:30 | Dispense complete for COTTON, final dispense weight was 0.0354\n\n\n"
"22/09/2015 11:50:04 | Dispense complete for COTTON, final dispense weight was 0.0294")
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