@simonpalepin/rgba-parser
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i @simonpalepin/rgba-parser

Weekly Downloads

0

Version

0.0.1

License

none

Unpacked Size

75.1 kB

Total Files

24

Last publish

Collaborators

  • simonpalepin