function toRegex(glob, options) {
  // clone options to prevent  mutating the original object
  var opts = Object.create(options || {});
  var flags = opts.flags || '';
  if (opts.nocase && flags.indexOf('i') === -1) {
    flags += 'i';
  }

  var parsed = expand(glob, opts);

  // pass in tokens to avoid parsing more than once
  opts.negated = opts.negated || parsed.negated;
  opts.negate = opts.negated;
  glob = wrapGlob(parsed.pattern, opts);
  var re;

  try {
    re = new RegExp(glob, flags);
    return re;
  } catch (err) {
    err.reason = 'micromatch invalid regex: (' + re + ')';
    if (opts.strict) throw new SyntaxError(err);
  }

  // we're only here if a bad pattern was used and the user
  // passed `options.silent`, so match nothing
  return /$^/;
}
function toRegex(glob, options) {
  
  var opts = Object.create(options || {});
  var flags = opts.flags || '';
  if (opts.nocase && flags.indexOf('i') === -1) {
    flags += 'i';
  }

  var parsed = expand(glob, opts);

  
  opts.negated = opts.negated || parsed.negated;
  opts.negate = opts.negated;
  glob = wrapGlob(parsed.pattern, opts);
  var re;

  try {
    re = new RegExp(glob, flags);
    return re;
  } catch (err) {
    err.reason = 'micromatch invalid regex: (' + re + ')';
    if (opts.strict) throw new SyntaxError(err);
  }

  
  
  return /$^/;
}
function toRegex ( glob , options ) { // clone options to prevent  mutating the original object var opts = Object . create ( options || { } ) ; var flags = opts . flags || '' ; if ( opts . nocase && flags . indexOf ( 'i' ) === - 1 ) { flags += 'i' ; } var parsed = expand ( glob , opts ) ; // pass in tokens to avoid parsing more than once opts . negated = opts . negated || parsed . negated ; opts . negate = opts . negated ; glob = wrapGlob ( parsed . pattern , opts ) ; var re ; try { re = new RegExp ( glob , flags ) ; return re ; } catch ( err ) { err . reason = 'micromatch invalid regex: (' + re + ')' ; if ( opts . strict ) throw new SyntaxError ( err ) ; } // we're only here if a bad pattern was used and the user // passed `options.silent`, so match nothing return / $^ / ; }
Create and cache a regular expression for matching
file paths.

If the leading character in the `glob` is `!`, a negation
regex is returned.

@param  {String} `glob`
@param  {Object} `options`
@return {RegExp}
Create and cache a regular expression for matching file paths .