function isGlob(str) {
  const chars = {
    "{": "}",
    "(": ")",
    "[": "]",
  };
  const regex =
    /\\(.)|(^!|\*|[\].+)]\?|\[[^\\\]]+\]|\{[^\\}]+\}|\(\?[:!=][^\\)]+\)|\([^|]+\|[^\\)]+\))/;
  if (str === "") {
    return false;
  }
  let match;
  while (match = regex.exec(str)) {
    if (match[2]) return true;
    let idx = match.index + match[0].length;
    // if an open bracket/brace/paren is escaped,
    // set the index to the next closing character
    const open = match[1];
    const close = open ? chars[open] : null;
    if (open && close) {
      const n = str.indexOf(close, idx);
      if (n !== -1) {
        idx = n + 1;
      }
    }
    str = str.slice(idx);
  }
  return false;
}
/** Test whether the given string is a glob */
Test whether the given string is a glob
Test whether the given string is a glob
function isGlob(str) {
  const chars = {
    "{": "}",
    "(": ")",
    "[": "]",
  };
  const regex =
    /\\(.)|(^!|\*|[\].+)]\?|\[[^\\\]]+\]|\{[^\\}]+\}|\(\?[:!=][^\\)]+\)|\([^|]+\|[^\\)]+\))/;
  if (str === "") {
    return false;
  }
  let match;
  while (match = regex.exec(str)) {
    if (match[2]) return true;
    let idx = match.index + match[0].length;
    const open = match[1];
    const close = open ? chars[open] : null;
    if (open && close) {
      const n = str.indexOf(close, idx);
      if (n !== -1) {
        idx = n + 1;
      }
    }
    str = str.slice(idx);
  }
  return false;
}
function isGlob ( str ) { const chars = { "{" : "}" , "(" : ")" , "[" : "]" , } ; const regex = / \\(.)|(^!|\*|[\].+)]\?|\[[^\\\]]+\]|\{[^\\}]+\}|\(\?[:!=][^\\)]+\)|\([^|]+\|[^\\)]+\)) / ; if ( str === "" ) { return false ; } let match ; while ( match = regex . exec ( str ) ) { if ( match [ 2 ] ) return true ; let idx = match . index + match [ 0 ] . length ; const open = match [ 1 ] ; const close = open ? chars [ open ] : null ; if ( open && close ) { const n = str . indexOf ( close , idx ) ; if ( n !== - 1 ) { idx = n + 1 ; } } str = str . slice ( idx ) ; } return false ; }
Test whether the given string is a glob
Test whether the given string is a glob
// if an open bracket/brace/paren is escaped, // set the index to the next closing character