MAC address regex pattern

Copy and test a JavaScript regex for MAC addresses, with examples and a one-click link to the regex tester.

MAC address regex pattern

Validate whole value

Use anchors to check whether the complete value matches.

Regex: ^(?:[0-9a-f]{2}[:-]){5}[0-9a-f]{2}$

Flags: i

Search in text

Find matching fragments inside a larger block of text.

Regex: \b(?:[0-9a-f]{2}[:-]){5}[0-9a-f]{2}\b

Flags: gi

Examples that match

  • 00:1A:2B:3C:4D:5E
  • aa-bb-cc-dd-ee-ff

Examples that do not match

  • 001A2B3C4D5E
  • gg:11:22:33:44:55