code: function parseQuery(query, ignoreCase, smartCase) {
        // Check if the query is already a regex.
        if (query instanceof RegExp) { return query; }
        // First try to extract regex + flags from the input. If no flags found,
        // extract just the regex. IE does not accept flags directly defined in
        // the regex string in the form /regex/flags
        var slashes = findUnescapedSlashes(query);
        var regexPart;
        var forceIgnoreCase;
        if (!slashes.length) {
          // Query looks like 'regexp'
          regexPart = query;
        } else {
          // Query looks like 'regexp/...'
          regexPart = query.substring(0, slashes[0]);
          var flagsPart = query.substring(slashes[0]);
          forceIgnoreCase = (flagsPart.indexOf('i') != -1);
        }
        if (!regexPart) {
          return null;
        }
        if (smartCase) {
          ignoreCase = (/^[^A-Z]*$/).test(regexPart);
        }
        var regexp = new RegExp(regexPart,
            (ignoreCase || forceIgnoreCase) ? 'i' : undefined);
        return regexp;
      }
docs: Extract the regular expression from the query and return a Regexp object.
  Returns null if the query is blank.
  If ignoreCase is passed in, the Regexp object will have the 'i' flag set.
  If smartCase is passed in, and the query contains upper case letters,
  then ignoreCase is overridden, and the 'i' flag will not be set.
  If the query contains the /i in the flag part of the regular expression,
  then both ignoreCase and smartCase are ignored, and 'i' will be passed
  through to the Regex object.