@simonpalepin/rgba-regexp
v0.0.4
Published
Provides bulletproof RGBA/RGB regexp with capture groups & css4 syntax support.
Downloads
8
Readme
Goal
Provide bulletproof RGB/RGBA regexp with css4 syntax support. You use capture groups matches to extract values.
| RegExp | Color Space | Matches | Css Color Value
| :------ | :------ | :------- | :------- |
| numberRGB | rgb
| rgb(255, 255, 255)
| <number>, <number>, <number>
|
| numberRGB | rgb
| rgb(.5, 25.5, 255.0)
| " " |
| numberRGBA | rgba
| rgba(255, 25.5, 255, 1%)
| <number>, <number>, <number>, <alpha-value>
|
| numberRGBACss4 | rgba
| rgba(255, 25.5, 255, 1)
| " " |
| percentRGB | rgb
| rgb(100%, 100.0%, .2%)
| <percent>, <percent>, <percent>, <alpha-value>
|
| percentRGB | rgb
| rgb(100%, 100.0%, .2)
| " " |
| percentRGBA | rgba
| rgba(100%, 100.0%, 10%, .2%)
| " " |
| percentRGBACss4 | rgba
| rgba(255 100.0 35 /.2%)
| <number> <number> <number> /<alpha-value>
|
| percentRGBACss4 | rgba
| rgba(100% 100.0% / .2)
| <percent> <percent> <percent> /<alpha-value>
|
Installation
npm i @simonpalepin/rgba-regexp
OR
yarn add @simonpalepin/rgba-regexp
Usage
import { rgbaRegexp } from '@simonpalepin/rgba-regexp';
if(rgbaRegexp.numRGBA.test('rgb(255, 100, 20.5)')) {
...
}
Comments?
Please don't hesitate