Product
Introducing Java Support in Socket
We're excited to announce that Socket now supports the Java programming language.
The hsl-regex package provides a regular expression specifically designed to match HSL (Hue, Saturation, Lightness) color codes in strings. This can be particularly useful for validating and extracting HSL color values from text content in web development and software projects that deal with color data.
HSL Color Matching
This feature allows you to match HSL color values within a string. The provided code sample demonstrates how to use the hsl-regex package to find HSL values in a CSS style declaration.
const hslRegex = require('hsl-regex');
const text = 'background-color: hsl(210, 50%, 50%);';
const matches = text.match(hslRegex());
console.log(matches);
Similar to hsl-regex, color-regex offers regex patterns for matching various color formats, including HSL. It provides a broader scope by supporting not only HSL but also HEX, RGB, and other color models. This makes color-regex more versatile if you need support for multiple color formats.
While rgb-regex is focused on matching RGB color formats, it serves a similar purpose to hsl-regex by providing regex patterns for color values. It is less suitable if you specifically need to match HSL colors but is ideal for projects that predominantly deal with RGB color data.
Regex for matching HSL colors.
npm install --save hsl-regex
var hslRegex = require('hsl-regex');
hslRegex({ exact: true }).test('hsl(123, 45%, 67%)'); // => true
hslRegex({ exact: true }).test('foo bar'); // => false
hslRegex({ exact: true }).exec('hsl(1, 1.111%, 1.1111%)');
// => [
// 'hsl(1, 1.111%, 1.1111%)',
// '1',
// '1.111%',
// '1.1111%',
// index: 0,
// input: 'hsl(1, 1.111%, 1.1111%)'
// ]
'hsl(123, 45%, 67%) cats and dogs'.match(hslRegex());
// = ['hsl(123, 45%, 67%)']
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 matching HSL colors.
We found that hsl-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.
Product
We're excited to announce that Socket now supports the Java programming language.
Security News
Socket detected a malicious Python package impersonating a popular browser cookie library to steal passwords, screenshots, webcam images, and Discord tokens.
Security News
Deno 2.0 is now available with enhanced package management, full Node.js and npm compatibility, improved performance, and support for major JavaScript frameworks.