RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

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
Bad Good

Enter New Comment

Title

Name

Comment

Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

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])$


Copyright © 2001-2024, RegexAdvice.com | ASP.NET Tutorials