function rewrite(match, paren, backref) {
        var name = captureNames[numCaptures - numPriorCaptures];

        // Capturing group
        if (paren) {
            ++numCaptures;
            // If the current capture has a name, preserve the name
            if (name) {
                return '(?<' + name + '>';
            }
        // Backreference
        } else if (backref) {
            // Rewrite the backreference
            return '\\' + (+backref + numPriorCaptures);
        }

        return match;
    }
Returns an XRegExp object that is the union of the given patterns. Patterns can be provided as
regex objects or strings. Metacharacters are escaped in patterns provided as strings.
Backreferences in provided regex objects are automatically renumbered to work correctly within
the larger combined pattern. Native flags used by provided regexes are ignored in favor of the
`flags` argument.

@memberOf XRegExp
@param {Array} patterns Regexes and strings to combine.
@param {String} [flags] Any combination of XRegExp flags.
@param {Object} [options] Options object with optional properties:
  - `conjunction` {String} Type of conjunction to use: 'or' (default) or 'none'.
@returns {RegExp} Union of the provided regexes and strings.
@example

XRegExp.union(['a+b*c', /(dogs)\1/, /(cats)\1/], 'i');
// -> /a\+b\*c|(dogs)\1|(cats)\2/i

XRegExp.union([/man/, /bear/, /pig/], 'i', {conjunction: 'none'});
// -> /manbearpig/i