Skip to main content
Regexflux

MAC Address

intermediate

Matches MAC addresses in common formats (colon, hyphen, or dot separated).

macnetworkhardwarevalidation

Pattern

/(?:[0-9a-fA-F]{2}[:-]){5}[0-9a-fA-F]{2}|(?:[0-9a-fA-F]{4}\.){2}[0-9a-fA-F]{4}/g

Try It

0 of 6 strings matched

Explanation

Matches MAC addresses in three formats: colon-separated (00:1A:2B:3C:4D:5E), hyphen-separated (00-1A-2B-3C-4D-5E), or Cisco dot notation (001A.2B3C.4D5E).

Test Strings

Matching

  • 00:1A:2B:3C:4D:5E
  • 00-1A-2B-3C-4D-5E
  • 001A.2B3C.4D5E

Non-matching

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

Language Compatibility

LanguageSupport
JSFull support
PYTHONFull support
JAVAFull support
PHPFull support
GOFull support

Code Snippets

const regex = /(?:[0-9a-fA-F]{2}[:-]){5}[0-9a-fA-F]{2}|(?:[0-9a-fA-F]{4}\.){2}[0-9a-fA-F]{4}/g;
const text = "your text here";
const matches = text.match(regex);
console.log(matches);

Related Patterns