Regular Expressions 101

Sponsors

Library entries

1
javascript

HTML注释

HTML注释
Submitted by anonymous - 2 months ago
1
javascript

phone regex

phone regex
Submitted by antiai - a month ago
1
javascript

提取步骤1

提取步骤1
Submitted by liangchao - a month ago
1
javascript

array path

Extract the array path from a nested path
Submitted by anonymous - 11 days ago
1
javascript

Match HMTL/WXML tag and class

Match HMTL/WXML tag and class
Submitted by ice breaker - 9 days ago

CSS Colors: RGB(A), HSL(A), HEX(3,4,6,8), var(--tw-color), etc...

Vote

2

Regular Expression
javascript

/
^\s*(color|background[-color]*||[a-zA-Z0-9-_]+)??[\s:=]*[\s]*(?:(\b(rgb)\s*?\(\s*?(000|0?\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\s*?,\s*?(000|0?\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\s*?,\s*?(000|0?\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\s*?\))|(\b(rgba)\s*?\(\s*?(000|0?\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\s*?,\s*?(000|0?\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\s*?,\s*?(000|0?\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\s*?,\s*?(0|0\.\d*|1|1.0*)\s*?\))\B|(\b(transparent)|(inherit)|(initial)|(currentColor)|(var)[(]([-]{2}[^)]+)[)])|(#([a-fA-F0-9]){3,4})|(#([a-fA-F0-9]){6,8})|(\b(hsl)\s*?\(\s*?(000|0?\d{1,2}|[1-2]\d\d|3[0-5]\d|360)\s*?,\s*?(000|100|0?\d{2}|0?0?\d)%\s*?,\s*?(000|100|0?\d{2}|0?0?\d)%\s*?\)$)|(\b(hsla)\s*?\(\s*?(000|0?\d{1,2}|[1-2]\d\d|3[0-5]\d|360)\s*?,\s*?(000|100|0?\d{2}|0?0?\d)%\s*?,\s*?(000|100|0?\d{2}|0?0?\d)%\s*?,\s*?(0|0\.\d*|1|1.0*)\s*?\)\b))
/
gm

Description

Loading markdown...
Submitted by Nicholas Berlette (@nberlette) - 6 months ago