All Projects → regexhq → hex-color-regex

regexhq / hex-color-regex

Licence: MIT License
Regular expression for matching hex color values from string.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to hex-color-regex

colors-convert
🦚 A simple colors library
Stars: ✭ 15 (-48.28%)
Mutual labels:  hex, colors, hex-color
dregex
Dregex is a JVM library that implements a regular expression engine using deterministic finite automata (DFA). It supports some Perl-style features and yet retains linear matching time, and also offers set operations.
Stars: ✭ 37 (+27.59%)
Mutual labels:  regex, regular-expression
pamatcher
A pattern matching library for JavaScript iterators
Stars: ✭ 23 (-20.69%)
Mutual labels:  regex, regular-expression
go-rainbow
Golang Helper for beautiful CLI Applications
Stars: ✭ 86 (+196.55%)
Mutual labels:  hex, colors
termco
Regular Expression Counts of Terms and Substrings
Stars: ✭ 24 (-17.24%)
Mutual labels:  regex, regular-expression
es6-template-regex
Regular expression for matching es6 template delimiters in a string.
Stars: ✭ 15 (-48.28%)
Mutual labels:  regex, regular-expression
CVparser
CVparser is software for parsing or extracting data out of CV/resumes.
Stars: ✭ 28 (-3.45%)
Mutual labels:  regex, regular-expression
cheat-sheet-pdf
📜 A Cheat-Sheet Collection from the WWW
Stars: ✭ 728 (+2410.34%)
Mutual labels:  regex, regular-expression
globrex
Glob to regular expression with support for extended globs.
Stars: ✭ 52 (+79.31%)
Mutual labels:  regex, regular-expression
hex-rgba
Convert HEX to RGBA
Stars: ✭ 12 (-58.62%)
Mutual labels:  hex, colors
regexp-expand
Show the ELisp regular expression at point in rx form.
Stars: ✭ 18 (-37.93%)
Mutual labels:  regex, regular-expression
RgxGen
Regex: generate matching and non matching strings based on regex pattern.
Stars: ✭ 45 (+55.17%)
Mutual labels:  regex, regular-expression
Regex
🔤 Swifty regular expressions
Stars: ✭ 311 (+972.41%)
Mutual labels:  regex, regular-expression
LLRegex
Regular expression library in Swift, wrapping NSRegularExpression.
Stars: ✭ 18 (-37.93%)
Mutual labels:  regex, regular-expression
cregex
A small implementation of regular expression matching engine in C
Stars: ✭ 72 (+148.28%)
Mutual labels:  regex, regular-expression
regex
Regular expressions for Prolog
Stars: ✭ 16 (-44.83%)
Mutual labels:  regex, regular-expression
doi-regex
Regular expression for matching DOIs
Stars: ✭ 28 (-3.45%)
Mutual labels:  regex, regular-expression
RegexReplacer
A flexible tool to make complex replacements with regular expression
Stars: ✭ 38 (+31.03%)
Mutual labels:  regex, regular-expression
expand-brackets
Expand POSIX bracket expressions (character classes) in glob patterns.
Stars: ✭ 26 (-10.34%)
Mutual labels:  regex, regular-expression
color
A library of well-tested helper methods for working with colors.
Stars: ✭ 13 (-55.17%)
Mutual labels:  hex, hex-color

hex-color-regex npmjs.com The MIT License

The best regular expression (regex) for matching hex color values from string.

code climate standard code style travis build status coverage status dependency status

Install

npm i hex-color-regex --save
npm test

Usage

For more use-cases see the tests

  • [opts] {Object} pass strict: true for strict mode
  • return {RegExp}

Example

var hexColorRegex = require('hex-color-regex')

hexColorRegex().test('#f3f}') //=> true
hexColorRegex({strict: true}).test('#f3f}') //=> false

hexColorRegex().test('foo #f3f bar') //=> true
hexColorRegex({strict: true}).test('foo #f3f bar') //=> false

hexColorRegex().test('#a54f2c}') //=> true
hexColorRegex({strict: true}).test('#a54f2c}') //=> false

hexColorRegex().test('foo #a54f2c bar') //=> true
hexColorRegex({strict: true}).test('foo #a54f2c bar') //=> false

hexColorRegex().test('#ffff') //=> false
hexColorRegex().test('ffff') //=> false

hexColorRegex().test('#fff') //=> true
hexColorRegex().test('fff') //=> false

hexColorRegex().test('#4g1') //=> false
hexColorRegex().test('4g1') //=> false
hexColorRegex().test('#zY1') //=> false
hexColorRegex().test('zY1') //=> false
hexColorRegex().test('#7f68ZY') //=> false
hexColorRegex().test('7f68ZY') //=> false
hexColorRegex().test('ffffff') //=> false

hexColorRegex().test('#afebe3') //=> true
hexColorRegex().test('#AFEBE3') //=> true
hexColorRegex().test('#3cb371') //=> true
hexColorRegex().test('#3CB371') //=> true
hexColorRegex().test('#556b2f') //=> true
hexColorRegex().test('#556B2F') //=> true
hexColorRegex().test('#708090') //=> true
hexColorRegex().test('#7b68ee') //=> true
hexColorRegex().test('#7B68EE') //=> true
hexColorRegex().test('#eeeeee') //=> true
hexColorRegex().test('#ffffff') //=> true
hexColorRegex().test('#111111') //=> true

hexColorRegex().test('#afe') //=> true
hexColorRegex().test('#AF3') //=> true
hexColorRegex().test('#3cb') //=> true
hexColorRegex().test('#3CB') //=> true
hexColorRegex().test('#b2f') //=> true
hexColorRegex().test('#5B2') //=> true
hexColorRegex().test('#708') //=> true
hexColorRegex().test('#68e') //=> true
hexColorRegex().test('#7AF') //=> true
hexColorRegex().test('#777') //=> true
hexColorRegex().test('#FFF') //=> true
hexColorRegex().test('#fff') //=> true

Matching groups

  • match[0] hex value with hash - #f3f3f3
  • match[1] hex value without the hash - f3f3f3

Example

hexColorRegex().exec('foo #fff bar')
//=> [ '#fff', 'fff', index: 4, input: 'foo #fff bar' ]

hexColorRegex({strict: true}).exec('foo #fff bar')
//=> null

hexColorRegex().exec('foo #f3f3f3 bar')
//=> [ '#f3f3f3', 'f3f3f3', index: 4, input: 'foo #f3f3f3 bar' ]

hexColorRegex({strict: true}).exec('foo #f3f3f3 bar')
//=> null

Related

  • benz: Compose your control flow with absolute elegance. Support async/await, callbacks, thunks, generators, promises, observables, child… more
  • is-hexcolor: Check that given value is valid hex color, using hex-color-regex - the best regex for… more
  • is-ansi: Check that given string contain ANSI color codes, without CLI
  • is-missing: Check that given name or user/repo exists in npm registry or in github as user… more
  • is-kindof: Check type of given javascript value. Support promises, generators, streams, and native types. Thin wrapper… more
  • is-typeof-error: Check that given value is any type of error and instanceof Error
  • is-async-function: Check that given function is async (callback) function or not. Trying to guess that based… more
  • kind-error: Correct inheriting from Error. Supports constructing from an object of properties - focused on assertion.
  • kind-of-extra: Extends kind-of type check utility with support for promises, generators, streams and errors. Like `kindof(Promise.resolve(1))… more
  • vez: Middleware composition at new level. Ultimate alternative to ware, plugins, koa-compose and composition packages. Allows… more

Contributing

Pull 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.

Charlike Make Reagent new message to charlike freenode #charlike

tunnckocore.tk keybase tunnckocore tunnckoCore npm tunnckoCore twitter tunnckoCore github

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].