View

A MAC address regex

  1. # Works with dash “-” and colon “:” as a separator
  2. # The “/i” modifier at the end makes it case-insensitive (Perl-like syntax)
  3. /^([0-9A-F]{2}[:-]){5}[0-9A-F]{2}$/i
  4. # General syntax (match lower and upper case)
  5. ^([0-9a-fA-F]{2}[:-]){5}[0-9a-fA-F]{2}$

You may also like