import re
regex = re.compile(r"^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$", flags=re.MULTILINE)
test_str = ("11-D6-D4-D7-B0-80\n"
"B5-42-A1-A7-33-B1\n"
"8C-03-74-2B-C6-D1\n"
"B5-5E-20-CH-1D-E6\n"
"7F-83-86-B6-7A-93\n"
"31-CE-78-13-75-FF\n"
"E5-EF-62-80-46-BC\n"
"D8-G2-44-10-49-E8\n"
"C6-45-E2-C5-D8-B3\n"
"F2-CA-6C-77-C3-7D\n"
"05-A0-4F-8A-F9-71\n"
"82-7B-DZ-D5-06-DA\n"
"B8-9F-45-90-D9-B3\n"
"82-7B-D6-D5-06-DA\n")
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