Regular Expressions 101

Community Patterns

CSS colour hex matcher

1

Regular Expression
PCRE (PHP <7.3)

/
#([[:xdigit:]]{3}){1,2}\b
/
img

Description

Matches instances of colour hex codes with either 3 or 6 digits.

Submitted by Tom Higginson - 9 years ago