rewrite = function (match, paren, backref) {
                var name = captureNames[numCaptures - numPriorCaptures];
                if (paren) { // Capturing group
                    ++numCaptures;
                    if (name) { // If the current capture has a name
                        return "(?<" + name + ">";
                    }
                } else if (backref) { // 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. 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.
@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([XRegExp('(?<pet>dogs)\\k<pet>'), XRegExp('(?<pet>cats)\\k<pet>')]);
// -> XRegExp('(?<pet>dogs)\\k<pet>|(?<pet>cats)\\k<pet>')