E-Scribe : a programmer’s blog

About Me

PBX I'm Paul Bissex. I build web applications using open source software, especially Django. 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. Then I built operations software at a photography school. Then I helped big media serve 40 million pages a day. Then I worked on a translation services API doing millions of dollars of business. Now I'm building the core platform of a global startup accelerator. Feel free to email me.


I co-wrote "Python Web Development with Django". It was the first book to cover the long-awaited Django 1.0. Published by Addison-Wesley and still in print!


Built using Django, served with gunicorn and nginx. The database is SQLite. Hosted on a FreeBSD VPS at Johncompanies.com. Comment-spam protection by Akismet.


Pile o'Tags

Stuff I Use

Bitbucket, Debian Linux, Django, Emacs, FreeBSD, Git, jQuery, LaunchBar, macOS, Markdown, Mercurial, Python, S3, SQLite, Sublime Text, xmonad

Spam Report

At least 237138 pieces of comment spam killed since 2008, mostly via Akismet.

A MAC address regex

Today I worked on a form and script used for registering users on a restricted-access wireless network. Here's a nice compact regex for checking that MAC addresses have been entered in the correct format. (If you're using this in a double-quoted PHP string, escape the "$" with a backslash.)


Friday, September 8th, 2006

0 comments pending approval
Comment from Bjoern , 8 months later


great regex! exactly what I was looking for.

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-fA-F]{2}[:-]){5}[0-9a-fA-F]{2}$/i

Comment from Paul , 8 months later

Thanks for the update, Bjoern. The "/i" modifier at the end already makes it case-insensitive (assuming you're using Perl-compatible regexes), but adding the dash as a separator is a good improvement.

Comment from Jeremy , 4 years later

Thanks for this!

Added support for no separator...


Comment from Manohar Bhattarai , 5 years later

This link might give you all more insight. http://manoharbhattarai.wordpress.com/2012/02/17/regex-to-match-mac-address/

Comment from Manohar , 5 years later

Great regex. I have a link that explains to match all 3 types of mac addresses http://manoharbhattarai.wordpress.com/tag/regex-to-find-mac-address/

Comments are closed for this post. But I welcome questions/comments via email or Twitter.