🚀 Socket Launch Week 🚀 Day 3: Socket Acquires Coana.Learn More
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rgb-regex

Regex for RGB color strings.

1.0.1
latest
Version published
Weekly downloads
1.6M
-26.36%
Maintainers
1
Weekly downloads
 
Created

What is rgb-regex?

The rgb-regex package provides a regular expression for matching RGB color strings in text. It can be used to find and manipulate RGB color strings within strings of text in JavaScript applications.

What are rgb-regex's main functionalities?

Matching RGB strings

This feature allows you to match RGB color strings in a given text. The code sample demonstrates how to use the rgb-regex package to find an RGB string within a larger string.

const rgbRegex = require('rgb-regex');
const text = 'background: rgb(12, 34, 56);';
const match = text.match(rgbRegex());
console.log(match[0]); // 'rgb(12, 34, 56)'

Matching RGB strings with exact option

This feature allows you to match an exact RGB string without any additional characters. The code sample shows how to use the rgb-regex package to test for an exact RGB string match.

const rgbRegex = require('rgb-regex');
const exactMatch = 'rgb(12, 34, 56)';
const isExactMatch = rgbRegex({ exact: true }).test(exactMatch);
console.log(isExactMatch); // true

Other packages similar to rgb-regex

FAQs

Package last updated on 02 Feb 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts