Please enable JavaScript to use regex101
Regular
Expressions
101
Support Regex101
Social
Info
Regex Editor
Community Library
Account
Regex Quiz
Order By
Most Recent
Most upvotes
Most downvotes
Highest Score
Lowest Score
Filter by Flavor
PCRE2 (PHP)
JavaScript
Python
Golang
Java
.NET 10.0 (C#)
Rust
POSIX ERE
POSIX BRE (grep/sed)
PCRE (Legacy)
Sponsors
digidib · when security, quality, and reliability matter
Community Library
Search community submissions...
0/512
Your search did not match anything
Community Library Entry
1
Regular Expression
Open Workspace
/
^
rgba
?
\(
(?:
\s
+
)?(?<r>
\d
+
(?<unit>
%
?
)
)(?:
\s
+
)?(?<separator>
[
\s
|,
]
)(?:
\s
+
)?(?<g>
\d
+
\k<unit>
)(?:
\s
+
)?
\k<separator>
(?:
\s
+
)?(?<b>
\d
+
\k<unit>
)(?:
\s
+
)?(?:
(?<=
(?:
,
.
+
)
)(?:
,
(?:
\s
+
)?(?<a>
(?:
\d
+
)?(?:
\.
?
\d
+
)
)
)?(?:
\s
+
)?
)?
\)
$
/
gm
Description
Created
·
2021-10-01 20:54
Updated
·
2021-10-03 13:52
Type
·
Match
Flavor
·
JavaScript
Pattern for matching actually valid RGB values.
validate separator (mixing spaces and commas between values is not valid)
validate if comma is used as separator if alpha channel is set
validate units (mixing percentage with integers is not valid)
extract
r
,
g
,
b
,
a
,
separator
and
unit
with named groups
Submitted by
BorisTB
Open Workspace