hexa-color-regex
Version:
regex for the future spec of hexa (hex with alpha)
42 lines (26 loc) • 1.12 kB
Markdown
A simple regex to match hexa style colors. hexa is an emerging CSS standard of using hex values to determine color and opacity. Example `
```bash
npm i hexa-color-regex --save
npm test
```
- `[opts]` **{Object}** pass `strict: true` for strict mode
- `return` **{RegExp}**
```javascript
regexCreator().test('#abcd'); // true
regexCreator().test('color: #f0d6'); // true
regexCreator().test('#f06d06ff'); // true
regexCreator({strict: true}).test('#abcd'); // true
regexCreator({strict: true}).test('color: #abcd'); // false
```
Take care that test cases pass and jscs comes back with no errors. Please try to emulate code style as it exists.
This code is largely based on [@tunnckoCore](https://github.com/tunnckoCore)'s [hex-color-regex](https://github.com/regexps/hex-color-regex) code and adapted for hexa.
MIT
- [btholt](http://twitter.com/holtbt)