Skip to main content
AllDevToolsHub
Back to all patterns

MAC Address Validation

Web & Network

Validates MAC addresses in colon-separated (AA:BB:CC:DD:EE:FF) or hyphen-separated (AA-BB-CC-DD-EE-FF) formats.

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

How it works

A MAC address is a 48-bit hardware identifier represented as six groups of two hexadecimal digits. This pattern accepts both colon and hyphen separators. It does not accept the Cisco dot-notation format (AAAA.BBBB.CCCC).

Test Cases

Should Match

  • 00:1A:2B:3C:4D:5E
  • AA-BB-CC-DD-EE-FF
  • ff:ff:ff:ff:ff:ff

Should NOT Match

  • 00:1A:2B:3C:4D
  • GG:HH:II:JJ:KK:LL
  • 001A.2B3C.4D5E

Quick Summary

Validates MAC addresses in colon (AA:BB:CC:DD:EE:FF) or hyphen (AA-BB-CC-DD-EE-FF) notation. Case-insensitive. Does not match Cisco dot notation (AAAA.BBBB.CCCC).

Key Takeaways

Key Takeaways

  • Accepts both : and - as separators (but not mixed in the same address)
  • Case-insensitive, both uppercase and lowercase hex digits are valid
  • Does not match Cisco dot notation, add AAAA.BBBB.CCCC alternation if needed
  • The broadcast address FF:FF:FF:FF:FF:FF is a valid match
Use Cases

When to use it

  • Validating MAC address inputs in network management tools
  • Parsing ARP tables or DHCP lease files
  • Filtering network device registrations
Watch out

Common Mistakes

  • Mixing separators in the same address, the pattern requires consistent separators
  • Not normalizing to a canonical format (e.g., always lowercase with colons) before storage
FAQ

MAC Address Validation, Frequently Asked

Are MAC addresses unique?

Theoretically yes, the first 3 bytes (OUI) identify the manufacturer and the last 3 are device-specific. In practice, MAC addresses can be spoofed.

How do I normalize a MAC address?

Strip separators, lowercase all hex digits, then reinsert colons: 'aa:bb:cc:dd:ee:ff'.