Regex for MAC Address Validation — Colon, Hyphen, and Cisco Formats

Regex for MAC address validation in colon-separated, hyphen-separated, and Cisco dot-notation formats. Includes EUI-48 and EUI-64 patterns.

Data Validation

Detailed Explanation

Regex for MAC Address Validation

A MAC (Media Access Control) address is a 48-bit hardware identifier shown as six pairs of hex digits. Different vendors use different separators, and Cisco uses three groups of four digits.

Colon-Separated (most common)

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

Matches 00:1A:2B:3C:4D:5E.

Hyphen-Separated (Windows)

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

Matches 00-1A-2B-3C-4D-5E.

Cisco Dot Notation

^([0-9A-Fa-f]{4}\.){2}[0-9A-Fa-f]{4}$

Matches 001a.2b3c.4d5e.

Combined (any common format)

^(?:(?:[0-9A-Fa-f]{2}[:-]){5}[0-9A-Fa-f]{2}|(?:[0-9A-Fa-f]{4}\.){2}[0-9A-Fa-f]{4})$

EUI-64 (64-bit, IPv6 interface identifier)

^([0-9A-Fa-f]{2}:){7}[0-9A-Fa-f]{2}$

Matches 00:1A:2B:3C:4D:5E:6F:70.

Tested Examples

Input Matches Combined?
00:1A:2B:3C:4D:5E yes
00-1A-2B-3C-4D-5E yes
001A.2B3C.4D5E yes
00:1A:2B:3C:4D no (5 octets)
00:1A:2B:3C:4D:5G no (G is not hex)
00:1a:2b:3c:4d:5e yes (case insensitive)

Special Bits

The least-significant bit of the first octet indicates unicast (0) vs multicast (1). The second-to-least-significant bit indicates globally unique (0) vs locally administered (1). To match only unicast/globally-unique addresses, restrict the first octet: [0-9A-Fa-f][02468ACEace].

Use Case

Filtering DHCP lease logs by MAC, validating MAC entries in a network access control list, or normalizing MAC formats from mixed-vendor switch dumps before importing into an asset database.

Try It — Regex Cheat Sheet

Open full tool