What is a regular expression for a MAC Address?
The standard (IEEE 802) format for printing MAC-48 addresses in human-friendly form is six groups of two hexadecimal digits, separated by hyphens
-
or colons:
.
So:
^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$
A little hard on the eyes, but this:
/^(?:[[:xdigit:]]{2}([-:]))(?:[[:xdigit:]]{2}\1){4}[[:xdigit:]]{2}$/
will enforce either all colons or all dashes for your MAC notation.
(A simpler regex approach might permit A1:B2-C3:D4-E5:F6
, for example, which the above rejects.)