Regular Expressions 101

Community Library

Community Library Entry

5

Regular ExpressionOpen Workspace

/
^#?([0-9a-f]{6}|[0-9a-f]{3})$
/
i

Description
Created·2015-12-02 11:14
Type·Match
Flavor·PCRE (Legacy)

Validates hexadecimal color codes based on the following rule set:

  • Optionally starting with a hash.
  • 3 or 6 characters in length.
  • Using the [0-9a-f] character set.
Submitted by Nathaniel Blackburn
Open Workspace