Regex library
Regular expression for MAC addresses
Match 48-bit MAC addresses with colon or hyphen separators. Compact 12-hex form is rejected unless you extend the pattern.
^(?:[0-9A-Fa-f]{2}[:-]){5}[0-9A-Fa-f]{2}$
Runs 100% in your browser. Nothing you paste is uploaded, stored, or sent to a server.
Highlighted matches
How to use
- Scan the pre-filled pattern and the sample. Hits are highlighted; misses stay plain.
- Toggle flags if you need global or case-insensitive matching. The pattern is JavaScript / ECMAScript.
- Paste your own corpus. Nothing is sent to a server.
- Read the notes below before you drop the pattern into production — several of these are intentionally incomplete.
A MAC address is six octets. This pattern allows the two separators you see on Linux (colons) and Windows (hyphens), but not a mix in the same value.
Cisco-style 4-digit groups (A1B2.C3D4.E5F6) and bare 12-hex strings need a different expression.
What this pattern will not do
Case-insensitive hex.
Does not check locally administered or multicast bits.
FAQ
How do I allow the compact form?
Add an alternation: ^(?:[0-9A-Fa-f]{2}[:-]){5}[0-9A-Fa-f]{2}$|^[0-9A-Fa-f]{12}$.
Is this a device identifier I should log?
Treat it as potentially identifying. Hash or truncate if the log leaves your network.
Is the sample text uploaded?
No. The tester compiles the pattern with the browser’s RegExp engine and stays on the device.