Regular Expressions 101

Community Patterns

MAC address

0

Regular Expression
Python

r"
^(?:[0-9a-zA-Z]{2}([:-]?))(?:[0-9a-zA-Z]{2}\1){4}[0-9a-zA-Z]{2}$
"
g

Description

6 pairs of hexadecimal characters separated by either 5 dashes, or 5 colons, or no separators at all. Mixture of separators not allowed.

Submitted by anonymous - 7 years ago