Other Resources:
MAC address validation
According to the IEEE 802 specification, a MAC address has 6 groups of 2 hexadecimal digits separated by "-" or ":". For example, 0a-1b-3c-4d-5e-6f is a valid MAC address.
How to write a single regular expression to validate a MAC address described above?
✍: FYIcenter.com
Here is the regular expression for MAC address validation:
^((([0-9A-Fa-f]{2}:){5})|(([0-9A-Fa-f]{2}-){5}))[0-9A-Fa-f]{2}$
^ - begin of the string
[0-9A-Fa-f] - any hex digit
{2} - repeating 2 times
: - a single :
{5} - repeating 5 times
| - the OR logic
([0-9A-Fa-f]{2}-){5} - 5 times of 2 hex digits followed by -
$ - end of the string
2020-08-03, 0👍, 6💬
Popular Posts:
All credit card numbers issued by Diners Club must start with 300 through 305, 36 or 38 and have 14 ...
How to write a regular expression to validate GUID (Globally Unique IDentifier) or UUID (Universally...
A free online regular expression test tool that allows to try you regular expression pattern and see...
How to capture the Soso Spider entries from Web log file? Here are some Web log file entries: 127.0....
All credit card numbers issued by Diners Club must start with 300 through 305, 36 or 38 and have 14 ...