Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE2 (PHP >=7.3)

/
#[0-9a-f]{3}(?:[0-9a-f]{3})?(?=\W|$)
/
gm

Description

This regex will find any hexadecimal colour code, anywhere in your string

Support for: mini 3 letter codes normal 6 letter codes back to back codes

Submitted by anonymous - a year ago