Webflags: gi
CSS rgb() Color
Match CSS rgb() and rgba() color functions, including an optional alpha channel.
Try it in RegexPro →Available in
Pattern
regexengine-agnostic
rgba?\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}(?:\s*,\s*(?:0|1|0?\.\d+))?\s*\) (flags: gi)Raw source: rgba?\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}(?:\s*,\s*(?:0|1|0?\.\d+))?\s*\)
How it works
Matches rgb( or rgba( followed by three comma-separated 1–3 digit components and an optional fourth alpha component (0, 1, or decimal).
Examples
Input
rgb(255, 87, 51)Matches
rgb(255, 87, 51)
Input
rgba(0, 0, 0, 0.5)Matches
rgba(0, 0, 0, 0.5)
Input
color: blue;No match
—Common use cases
- •Stylesheet color extraction
- •Design token migration
- •Theme color auditing
- •CSS-in-JS transform tooling
Related patterns
CSS hsl() / hsla() Color
WebMatch CSS hsl() and hsla() color functions, capturing hue (0–360), saturation, lightness, and optional alpha.
Hex Color Code
WebMatch CSS hex color codes in both 3-digit (#RGB) and 6-digit (#RRGGBB) formats.
CSS Custom Property (Variable)
WebMatch CSS custom properties (variables) like `--brand-color` or `--font-size-lg`.
HTML5 Color Input Value
WebValidate the value of an HTML5 `<input type="color">` — exactly 6 hex digits with leading hash.