Gathering detailed insights and metrics for hex-color-regex
Gathering detailed insights and metrics for hex-color-regex
Gathering detailed insights and metrics for hex-color-regex
Gathering detailed insights and metrics for hex-color-regex
@types/hex-color-regex
TypeScript definitions for hex-color-regex
color-regex
Color regex. Easily check the format of any color. Use diverse color helpers available to verify any color.
is-hexcolor
Check that given value is valid hex color, using `hex-color-regex` - the best regex for matching hex color values
hexa-color-regex
regex for the future spec of hexa (hex with alpha)
Regular expression for matching hex color values from string.
npm install hex-color-regex
Typescript
Module System
Node Version
NPM Version
99.9
Supply Chain
99.5
Quality
75.2
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
1,446,993,203
Last Day
150,451
Last Week
2,413,595
Last Month
10,386,736
Last Year
119,788,797
MIT License
33 Stars
40 Commits
6 Forks
11 Watchers
1 Branches
12 Contributors
Updated on Jul 31, 2024
Minified
Minified + Gzipped
Latest Version
1.1.0
Package Id
hex-color-regex@1.1.0
Size
6.13 kB
NPM Version
5.0.0
Node Version
8.0.0
Published on
Jun 03, 2017
Cumulative downloads
Total Downloads
Last Day
-20.1%
150,451
Compared to previous day
Last Week
-8.7%
2,413,595
Compared to previous week
Last Month
7.7%
10,386,736
Compared to previous month
Last Year
-25.9%
119,788,797
Compared to previous year
1
The best regular expression (regex) for matching hex color values from string.
npm i hex-color-regex --save
npm test
For more use-cases see the tests
[opts]
{Object} pass strict: true
for strict modereturn
{RegExp}Example
1var hexColorRegex = require('hex-color-regex') 2 3hexColorRegex().test('#f3f}') //=> true 4hexColorRegex({strict: true}).test('#f3f}') //=> false 5 6hexColorRegex().test('foo #f3f bar') //=> true 7hexColorRegex({strict: true}).test('foo #f3f bar') //=> false 8 9hexColorRegex().test('#a54f2c}') //=> true 10hexColorRegex({strict: true}).test('#a54f2c}') //=> false 11 12hexColorRegex().test('foo #a54f2c bar') //=> true 13hexColorRegex({strict: true}).test('foo #a54f2c bar') //=> false 14 15hexColorRegex().test('#ffff') //=> false 16hexColorRegex().test('ffff') //=> false 17 18hexColorRegex().test('#fff') //=> true 19hexColorRegex().test('fff') //=> false 20 21hexColorRegex().test('#4g1') //=> false 22hexColorRegex().test('4g1') //=> false 23hexColorRegex().test('#zY1') //=> false 24hexColorRegex().test('zY1') //=> false 25hexColorRegex().test('#7f68ZY') //=> false 26hexColorRegex().test('7f68ZY') //=> false 27hexColorRegex().test('ffffff') //=> false 28 29hexColorRegex().test('#afebe3') //=> true 30hexColorRegex().test('#AFEBE3') //=> true 31hexColorRegex().test('#3cb371') //=> true 32hexColorRegex().test('#3CB371') //=> true 33hexColorRegex().test('#556b2f') //=> true 34hexColorRegex().test('#556B2F') //=> true 35hexColorRegex().test('#708090') //=> true 36hexColorRegex().test('#7b68ee') //=> true 37hexColorRegex().test('#7B68EE') //=> true 38hexColorRegex().test('#eeeeee') //=> true 39hexColorRegex().test('#ffffff') //=> true 40hexColorRegex().test('#111111') //=> true 41 42hexColorRegex().test('#afe') //=> true 43hexColorRegex().test('#AF3') //=> true 44hexColorRegex().test('#3cb') //=> true 45hexColorRegex().test('#3CB') //=> true 46hexColorRegex().test('#b2f') //=> true 47hexColorRegex().test('#5B2') //=> true 48hexColorRegex().test('#708') //=> true 49hexColorRegex().test('#68e') //=> true 50hexColorRegex().test('#7AF') //=> true 51hexColorRegex().test('#777') //=> true 52hexColorRegex().test('#FFF') //=> true 53hexColorRegex().test('#fff') //=> true
match[0]
hex value with hash - #f3f3f3
match[1]
hex value without the hash - f3f3f3
Example
1hexColorRegex().exec('foo #fff bar') 2//=> [ '#fff', 'fff', index: 4, input: 'foo #fff bar' ] 3 4hexColorRegex({strict: true}).exec('foo #fff bar') 5//=> null 6 7hexColorRegex().exec('foo #f3f3f3 bar') 8//=> [ '#f3f3f3', 'f3f3f3', index: 4, input: 'foo #f3f3f3 bar' ] 9 10hexColorRegex({strict: true}).exec('foo #f3f3f3 bar') 11//=> null
hex-color-regex
- the best regex for… morename
or user/repo
exists in npm registry or in github as user… moreError
. Supports constructing from an object of properties - focused on assertion.kind-of
type check utility with support for promises, generators, streams and errors. Like `kindof(Promise.resolve(1))… moreware
, plugins
, koa-compose
and composition
packages. Allows… morePull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
1 existing vulnerabilities detected
Details
Reason
Found 3/28 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-06-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More