Network & Web · In-Browser Regular Expression Lab
MAC Address Regex — Colon and Hyphen Hardware Addresses
Matches 6-byte IEEE 802 Media Access Control (MAC) hardware addresses with colons or hyphens.
Flags:
//none
Match Found
Load Sample:
Match Inspection & Details1 match
Match #1:00:1A:2B:3C:4D:5E
Test Samples Verification Matrix
Expected Valid Samples (Should Match)
00:1A:2B:3C:4D:5E Pass
a1-b2-c3-d4-e5-f6 Pass
FF:FF:FF:FF:FF:FF Pass
Expected Invalid Samples (Must Reject)
00:1A:2B:3C:4D Rejected (Pass)
00:1A:2B:3C:4D:5E:6F Rejected (Pass)
00:1Z:2B:3C:4D:5E Rejected (Pass)
Code Implementation Generator
// JavaScript / TypeScript (ES6+)
const pattern = /^(?:[0-9A-Fa-f]{2}[:-]){5}(?:[0-9A-Fa-f]{2})$/;
const text = "00:1A:2B:3C:4D:5E";
const isMatch = pattern.test(text);
console.log("Is Match:", isMatch);
if (isMatch) {
const matches = text.match(pattern);
console.log("Matches:", matches);
}Regular Expression Token Breakdown
Validates six pairs of hexadecimal characters separated by colons or hyphens. Each component of the regular expression serves a distinct syntactical purpose as mapped below:
| Token Pattern | Name / Component | Function & Rule |
|---|---|---|
| [0-9A-Fa-f]{2} | Hex byte | Two hexadecimal digits. |
| [:-] | Separator | Either a colon or a hyphen. |
| {5} | Repeat 5 times | Matches first five separated bytes. |
Frequently Asked Questions
How to support Cisco format (xxxx.xxxx.xxxx)?
Related Regular Expressions
Browse All 40 PatternsNetwork & Web
IPv4 Address Validator
Strictly validates IPv4 addresses ensuring each octet is within the valid 0 to 255 numerical range.
/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/Test regex
Network & Web
IPv6 Address Validator
Matches standard 8-group IPv6 addresses as well as compressed double-colon (::) formats.
/^(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$|^::1$|^::$/iTest regex
Data & Formatting
UUID v4 Identifier
Strictly matches version 4 UUIDs with 36 canonical characters including hyphens and version bit 4.
/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/Test regex