Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
Created·2025-05-19 11:06
Updated·2025-05-19 15:42
Flavor·PCRE2 (PHP)

/
^(?:([[:xdigit:]]{2})([^[:xdigit:]]?)(?1)(\2(?1))(?3){3}|((?1){2})((?2))(?4)\5(?4))$
/
gm
Open regex in editor

Description

This regular expression matches various MAC addresses formats. It doesn't care about the case, neither the separator character as long as the same is used. Take a look at the test strings to learn more.

Submitted by anonymous