Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
ECMAScript (JavaScript)

/
^#([A-F0-9]{3}){1,2}$
/
igm

Description

Matches against RGB (not to be confused with RGBa). Will match against any and all RGB Hexadecimal Formatted colors. Some example of the values this regular expression was created to match are: "#FFFFFF", "#FFF", "#ABCDEF", "#123456", "#18F", "#812"

MUST USE THE 'i' FLAG (insensitive)

Without the i flag the regular expression will only match against colors formatted with all uppercase letters.

Submitted by jD3V - 3 years ago (Last modified 3 years ago)