MAC Address
intermediateMatches 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}/gTry 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
| Language | Support |
|---|---|
| JS | Full support |
| PYTHON | Full support |
| JAVA | Full support |
| PHP | Full support |
| GO | Full 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);