Regex for validating mac address

Posted by / 01-Oct-2017 20:44

Regex for validating mac address

In our case user is allowed to enter mac address the way s/he wants: 000CF15698AD 00:0C: F: AD 00-0C-F1-56-98-AD So the perfect solution would be to apply regular expression like this one: /([a-f A-F0-9][:|\-]?

Monks, Does anyone have a regex that will successfully match a MAC address that is better than the following?

• From PHP to Python • Racebike building and software engineering • Understanding tuples vs.

lists in Python • The twenty-minute trouble ticket system • Tim Bray: "No New XML Languages" • How to use vim, really • You really should learn regular expressions • Quick, but not dirty, PHP Hi, great regex! It only does not match lower case also the windows output of ipconfig/all (using a dash as delimiter) is not covered here's my addition: /^([0-9a-f A-F][:-])[0-9a-f A-F]$/i Thanks for the update, Bjoern.

However, support for character range collation varies among implementation, so the result may vary.

In theory all mac addresses returned by programs in the wild would follow some standard like 2 hex digits in each separate group.

Started my career doing graphic design for newspapers and magazines in the '90s.

Then wrote tech commentary and reviews for Wired, Salon, Chicago Tribune, and others you never heard of.

I build web applications using open source software, especially Django.Thanks to the helpful CB people who assisted me with this: blakem, demerphq, davorg & Petruchio.Pramod Kumar Jha Catch those com filestelephone nr FCCjust an example Address_numbers_1Best regex ever URL path Full_Date_Filtering IPv4 Validator Name (1-9,-)Url checker with or without or https://GTalk [email protected]/FFB6F4C4F0F4A: Trx SS20.082150505497 BERHASIL, Harga 19.850, SN:41001307034697 Sisa Saldo: Rp. This definitely doesn't seem to meet any real-world standard for ensuring input is an actual MAC address.That is exactly 2^48, which means that both of the cases you are trying to exclude are theoretically re = /^(?! While that might not be important in this instance, I believe that the UX can be improved.

regex for validating mac address-29regex for validating mac address-7regex for validating mac address-19

I don't doubt that works but I'm more curious as to why my implementation fails as theoretically it would match even -4556-67 and I don't want to be hung up on the poor typing skills of the user giving me the mac.