Regular Expressions 101

Community Patterns

CSS RGB validation

0

Regular Expression
ECMAScript (JavaScript)

/
^rgba?\((?:(?:(?:[0-9]{1,3} ){2}[0-9]{1,3}|(?:[0-9]{1,3}% ){2}[0-9]{1,3}%)(?: \/ (?:[0-9]{1,3}%|1|0|0?\.[0-9]+))?|(?:(?:[0-9]{1,3}, ){2}[0-9]{1,3}|(?:[0-9]{1,3}%, ){2}[0-9]{1,3}%)(?:, (?:[0-9]{1,3}%|1|0|0?\.[0-9]+))?)\)$
/
gm

Description

It validates the RGB expression doesn't break the CSS parser.

Submitted by Martin - a year ago (Last modified a year ago)