Title |
Test
Find
Pattern Title
|
Expression |
^([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F])$ |
Description |
This will grep for a valid MAC address , with colons seperating octets. It will ignore strings too short or long, or with invalid characters. It will accept mixed case hexadecimal. Use extended grep. |
Matches |
01:23:45:67:89:ab | 01:23:45:67:89:AB | fE:dC:bA:98:76:54 |
Non-Matches |
01:23:45:67:89:ab:cd | 01:23:45:67:89:Az | 01:23:45:56: |
Author |
Rating:
Not yet rated.
Ted Rudyk
|
Source |
Ted Rudyk |
Your Rating |
|
Title: i'd use the following
Name: sdw
Date: 8/5/2005 6:34:18 PM
Comment:
^(?i:(?:[0-F]{2}[-:]?){5}[0-F]{2})$
shorter, only matches the full mac address, allows delimiter-less or ":" and "-".
if you set the "i" modifier outside, just
^(?:[0-F]{2}[-:]?){5}[0-F]{2}$
is enough
Title: optional and different delimiter
Name: Clemens Gruber
Date: 10/22/2004 7:27:00 AM
Comment:
this expression permits to use a delimiter or not (optional) -> [- :]? the question mark at the end and secondly permits different haracters as delimiter -> [- :]
^([0-9a-fA-F][0-9a-fA-F][- :]?){5}([0-9a-fA-F][0-9a-fA-F])$