Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
ECMAScript (JavaScript)

/
^(?<rgb>rgb\((?<red>\d{1,3}),\s*\d{1,3},\s*\d{1,3}\))$|^(?<rgba>rgba\(\d{1,3},\s*\d{1,3},\s*\d{1,3},\s*[01](\.\d{1,2})?\))$|^(?<hsla>hsla\(\d{1,3},\s*\d{1,3}%,\s*\d{1,3}%,\s*[01](\.\d{1,2})?\))$|^(?<hsl>hsl\(\d{1,3},\s*\d{1,3}%,\s*\d{1,3}%\))$|^(?<hex>#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})(\d{2})?)$|^(?<cmyk>cmyk\(\d{1,3}%,\s*\d{1,3}%,\s*\d{1,3}%,\s*\d{1,3}%\))$
/
gm

Description

This Regex can be used to validate the different format of colors in the HTML

Submitted by Pranomvignesh - 3 years ago