Regex for Matching a MAC Address

Matches a MAC address as six colon-separated pairs of hex digits.

Published October 11, 2026

Matches a MAC address as six colon-separated pairs of hex digits.

Key points

  • Some formats use hyphens instead of colons as separators — adjust the pattern to [:-] to accept both

Example

^([0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}$
More General articles