Socket
Socket
Sign inDemoInstall

rgb-regex

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    rgb-regex

Regex for RGB color strings.


Version published
Weekly downloads
2.8M
decreased by-0.48%
Maintainers
1
Install size
5.18 kB
Created
Weekly downloads
 

Package description

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

Readme

Source

rgb-regex

Build Status

Regex for RGB color strings.

Installation

npm install --save rgb-regex

Usage

var rgbRegex = require('rgb-regex');

rgbRegex({ exact: true }).test('rgb(12, 34, 56)');  // => true
rgbRegex({ exact: true }).test('unicorns');         // -> false
rgbRegex({ exact: true }).test('rgb(,,)');          // => false

rgbRegex().exec('rgb(12, 34, 56)');
// => [
//  '12',
//  '34',
//  '56',
//  index: 0,
//  input: 'rgb(12,34,56)'
// ]

'rgb(12, 34, 56) cats and dogs'.match(rgbRegex());
// = ['rgb(12, 34, 56)']

License

MIT

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Crafted with <3 by John Otander (@4lpine).


This package was initially generated with yeoman and the p generator.

Keywords

FAQs

Last updated on 02 Feb 2015

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc