code: function getMatchingChars(pattern) {
      pattern.lastIndex = nextchar - 1;
      var match = pattern.exec(chars);
      if (match && match.index === nextchar - 1) {
        match = match[0];
        nextchar += match.length - 1;
        /* Careful!  Make sure we haven't matched the EOF character! */
        if (input_complete && nextchar === numchars) {
          // Oops, backup one.
          match = match.slice(0, -1);
          nextchar--;
        }
        return match;
      } else {
        throw new Error("should never happen");
      }
    }
docs: Consume chars matched by the pattern and return them as a string. Starts matching at the current position, so users should drop the current char otherwise.