Title |
Test
Find
MAC address
|
Expression |
^([0-9A-F]{2}[:-]){5}([0-9A-F]{2})$ |
Description |
This regular expression will validate against a valid MAC address. The 6 bytes are hexadecimal and separated by semi colon or dash caracters. |
Matches |
01:23:45:67:89:AB |
Non-Matches |
01:23:45:67:89:X9 |
Author |
Rating:
Jeff Hervouet
|
Source |
|
Your Rating |
|
Title: Not restrictive enough
Name: Robert Springel
Date: 12/3/2016 10:27:47 PM
Comment:
I downvoted this, because it matches: "01-23:45:67:89:AB" or "01:23:45:67-89:AB" which it not should match
Better solution:
^[A-Fa-f\d]{2}([-:])(?:[A-Fa-f\d]{2}\1){4}[A-Fa-f\d]{2}$