fork download
  1. import re
  2.  
  3. regex = r"\b[0-9A-Fa-f]{2}([:.-])(?:[0-9A-Fa-f]{2}\1){4}(?:[0-9A-F]){2}\b"
  4. test_str = ("3D:F2:C9:A6:B3:4F\n\n"
  5. "4D:F5:C6:A8:B1:43\n\n"
  6. "4d.f5.c6.a8.b1.43\n\n"
  7. "4D-F5-C6-A8-B1-43")
  8.  
  9. matches = re.finditer(regex, test_str)
  10.  
  11. for matchNum, match in enumerate(matches, start=1):
  12. print (match.group())
Success #stdin #stdout 0.02s 9644KB
stdin
Standard input is empty
stdout
3D:F2:C9:A6:B3:4F
4D:F5:C6:A8:B1:43
4d.f5.c6.a8.b1.43
4D-F5-C6-A8-B1-43