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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

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: The rating for this expression. Jeff Hervouet
Source
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: 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}$


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