index.js 459 B

12345678910111213141516
  1. /*!
  2. * hex-color-regex <https://github.com/regexps/hex-color-regex>
  3. *
  4. * Copyright (c) 2015 Charlike Mike Reagent <@tunnckoCore> (http://www.tunnckocore.tk)
  5. * Released under the MIT license.
  6. */
  7. 'use strict'
  8. module.exports = function hexColorRegex(opts) {
  9. opts = opts && typeof opts === 'object' ? opts : {}
  10. return opts.strict
  11. ? /^#([a-f0-9]{3,4}|[a-f0-9]{4}(?:[a-f0-9]{2}){1,2})\b$/i
  12. : /#([a-f0-9]{3}|[a-f0-9]{4}(?:[a-f0-9]{2}){0,2})\b/gi
  13. }