packages/heml-styles/src/plugins/postcss-element-expander/coerceElements.js
function toRegExp (string) {
  if (isString(string) && string.startsWith('/') && string.lastIndexOf('/') !== 0) {
    const pattern = string.substr(1, string.lastIndexOf('/') - 1)
    const opts = string.substr(string.lastIndexOf('/') + 1).toLowerCase()

    return new RegExp(pattern, opts.includes('i') ? opts : `${opts}i`)
  }

  if (isString(string)) {
    return new RegExp(`^${escapeRegExp(string)}$`, 'i')
  }

  return string
}
function toRegExp (string) {
  if (isString(string) && string.startsWith('/') && string.lastIndexOf('/') !== 0) {
    const pattern = string.substr(1, string.lastIndexOf('/') - 1)
    const opts = string.substr(string.lastIndexOf('/') + 1).toLowerCase()

    return new RegExp(pattern, opts.includes('i') ? opts : `${opts}i`)
  }

  if (isString(string)) {
    return new RegExp(`^${escapeRegExp(string)}$`, 'i')
  }

  return string
}
function toRegExp ( string ) { if ( isString ( string ) && string . startsWith ( '/' ) && string . lastIndexOf ( '/' ) !== 0 ) { const pattern = string . substr ( 1 , string . lastIndexOf ( '/' ) - 1 ) const opts = string . substr ( string . lastIndexOf ( '/' ) + 1 ) . toLowerCase ( ) return new RegExp ( pattern , opts . includes ( 'i' ) ? opts : ` ${ opts } ` ) } if ( isString ( string ) ) { return new RegExp ( ` ${ escapeRegExp ( string ) } ` , 'i' ) } return string }
convert the given string to a regular expression
@param  {String|RegExp} prop  the string to convert
@return {RegExp}              the regular expression
convert the given string to a regular expression