Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
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.
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
The color-regex package provides regular expressions for matching color strings, including RGB, HEX, HSL, and more. It offers a broader range of color string matching compared to rgb-regex, which focuses solely on RGB.
The hex-color-regex package is specifically designed to match HEX color strings. While rgb-regex is for RGB color strings, hex-color-regex serves a similar purpose for a different color format.
Similar to rgb-regex, rgba-regex is designed to match RGBA color strings, which include an alpha channel for opacity. It is useful for cases where transparency needs to be considered in addition to RGB colors.
Regex for RGB color strings.
npm install --save rgb-regex
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)']
MIT
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)Crafted with <3 by John Otander (@4lpine).
This package was initially generated with yeoman and the p generator.
FAQs
Regex for RGB color strings.
The npm package rgb-regex receives a total of 2,592,599 weekly downloads. As such, rgb-regex popularity was classified as popular.
We found that rgb-regex demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.