🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hsla-regex

Regex for matching HSLA colors.

1.0.0
latest
100

Supply Chain Security

100

Vulnerability

81

Quality

76

Maintenance

100

License

Version published
Weekly downloads
2.6M
4.17%
Maintainers
1
Weekly downloads
 
Created

What is hsla-regex?

The hsla-regex npm package provides a regular expression for matching HSLA (Hue, Saturation, Lightness, Alpha) color strings. This can be useful for validating, parsing, or extracting HSLA color values from strings.

What are hsla-regex's main functionalities?

Match HSLA color strings

This feature allows you to match HSLA color strings within a larger string. The code sample demonstrates how to use the hsla-regex package to find an HSLA color string in a CSS declaration.

const hslaRegex = require('hsla-regex');
const str = 'background-color: hsla(120, 100%, 50%, 0.3);';
const match = str.match(hslaRegex());
console.log(match); // ['hsla(120, 100%, 50%, 0.3)']

Validate HSLA color strings

This feature allows you to validate whether a given string is a valid HSLA color string. The code sample shows how to use the hsla-regex package to check if a string is a valid HSLA color.

const hslaRegex = require('hsla-regex');
const isValidHsla = (str) => hslaRegex().test(str);
console.log(isValidHsla('hsla(120, 100%, 50%, 0.3)')); // true
console.log(isValidHsla('rgb(255, 0, 0)')); // false

Other packages similar to hsla-regex

FAQs

Package last updated on 30 Jan 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