Regular Expressions 101

JS Parse rgb or rgba CSS string

Open Workspace
  • PCRE2 (PHP)
  • Match
0

Regular Expression

/
rgba?\(\s*(25[0-5]|2[0-4]\d|1\d{1,2}|\d\d?)\s*,\s*(25[0-5]|2[0-4]\d|1\d{1,2}|\d\d?)\s*,\s*(25[0-5]|2[0-4]\d|1\d{1,2}|\d\d?)\s*,?\s*([01\.]\.?\d?)?\s*\)
/
gm

Description

This will parse and give you the values of an RGB or RGBA CSS style.

Submitted by Beau Beauchamp, WebTIGERS