code: function pyre(pattern, namedCaptures) {
    pattern = String(pattern || '').trim();
  
    // populate namedCaptures array and removed named captures from the `pattern`
    namedCaptures = namedCaptures == undefined ? [] : namedCaptures;
    var numGroups = 0;
    pattern = replaceCaptureGroups(pattern, function (group) {
      if (/^\(\?P[<]/.test(group)) {
        // Python-style "named capture"
        // It is possible to name a subpattern using the syntax (?P<name>pattern).
        // This subpattern will then be indexed in the matches array by its normal
        // numeric position and also by name.
        var match = /^\(\?P[<]([^>]+)[>]([^\)]+)\)$/.exec(group);
        if (namedCaptures) namedCaptures[numGroups] = match[1];
        numGroups++;
        return '(' + match[2] + ')';
      } else if ('(?:' === group.substring(0, 3)) {
        // non-capture group, leave untouched
        return group;
      } else {
        // regular capture, leave untouched
        numGroups++;
        return group;
      }
    });
  
    var regexp = new RegExp(pattern);
    regexp.pyreReplace = function(source, replacement) {
      var jsReplacement = pyreReplacement(replacement, namedCaptures);
      return source.replace(this, jsReplacement);
    }
    return regexp;
  }
docs: Returns a JavaScript RegExp instance from the given Python-like string.
  
  An empty array may be passsed in as the second argument, which will be
  populated with the "named capture group" names as Strings in the Array,
  once the RegExp has been returned.
  
  @param {String} pattern - Python-like regexp string to compile to a JS RegExp
  @return {RegExp} returns a JavaScript RegExp instance from the given `pattern`
  @public