code: function RegExpMakeCaptureGetter(n) {
    return function foo() {
      var index = n * 2;
      if (index >= NUMBER_OF_CAPTURES(RegExpLastMatchInfo)) return '';
      var matchStart = RegExpLastMatchInfo[CAPTURE(index)];
      var matchEnd = RegExpLastMatchInfo[CAPTURE(index + 1)];
      if (matchStart == -1 || matchEnd == -1) return '';
      return %_SubString(LAST_SUBJECT(RegExpLastMatchInfo), matchStart, matchEnd);
    };
  }
docs: The properties $1..$9 are the first nine capturing substrings of the last successful match, or ''.  The function RegExpMakeCaptureGetter will be called with indices from 1 to 9.