Files
Epicnabbo-Catalogus-Updated…/Optimized Atomcms daily updated/node_modules/xregexp/lib/xregexp.js
T
2025-11-25 22:42:56 +01:00

2036 lines
91 KiB
JavaScript

"use strict";
var _sliceInstanceProperty2 = require("@babel/runtime-corejs3/core-js-stable/instance/slice");
var _Array$from = require("@babel/runtime-corejs3/core-js-stable/array/from");
var _Symbol = require("@babel/runtime-corejs3/core-js-stable/symbol");
var _getIteratorMethod = require("@babel/runtime-corejs3/core-js/get-iterator-method");
var _Array$isArray = require("@babel/runtime-corejs3/core-js-stable/array/is-array");
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
_Object$defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
var _flags = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/flags"));
var _sort = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/sort"));
var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
var _parseInt2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/parse-int"));
var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
var _create = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/create"));
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (_Array$isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
function _unsupportedIterableToArray(o, minLen) { var _context9; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty2(_context9 = Object.prototype.toString.call(o)).call(_context9, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
/*!
* XRegExp 5.1.1
* <xregexp.com>
* Steven Levithan (c) 2007-present MIT License
*/
/**
* XRegExp provides augmented, extensible regular expressions. You get additional regex syntax and
* flags, beyond what browsers support natively. XRegExp is also a regex utility belt with tools to
* make your client-side grepping simpler and more powerful, while freeing you from related
* cross-browser inconsistencies.
*/
// ==--------------------------==
// Private stuff
// ==--------------------------==
// Property name used for extended regex instance data
var REGEX_DATA = 'xregexp'; // Optional features that can be installed and uninstalled
var features = {
astral: false,
namespacing: true
}; // Storage for fixed/extended native methods
var fixed = {}; // Storage for regexes cached by `XRegExp.cache`
var regexCache = {}; // Storage for pattern details cached by the `XRegExp` constructor
var patternCache = {}; // Storage for regex syntax tokens added internally or by `XRegExp.addToken`
var tokens = []; // Token scopes
var defaultScope = 'default';
var classScope = 'class'; // Regexes that match native regex syntax, including octals
var nativeTokens = {
// Any native multicharacter token in default scope, or any single character
'default': /\\(?:0(?:[0-3][0-7]{0,2}|[4-7][0-7]?)?|[1-9]\d*|x[\dA-Fa-f]{2}|u(?:[\dA-Fa-f]{4}|{[\dA-Fa-f]+})|c[A-Za-z]|[\s\S])|\(\?(?:[:=!]|<[=!])|[?*+]\?|{\d+(?:,\d*)?}\??|[\s\S]/,
// Any native multicharacter token in character class scope, or any single character
'class': /\\(?:[0-3][0-7]{0,2}|[4-7][0-7]?|x[\dA-Fa-f]{2}|u(?:[\dA-Fa-f]{4}|{[\dA-Fa-f]+})|c[A-Za-z]|[\s\S])|[\s\S]/
}; // Any backreference or dollar-prefixed character in replacement strings
var replacementToken = /\$(?:\{([^\}]+)\}|<([^>]+)>|(\d\d?|[\s\S]?))/g; // Check for correct `exec` handling of nonparticipating capturing groups
var correctExecNpcg = /()??/.exec('')[1] === undefined; // Check for ES6 `flags` prop support
var hasFlagsProp = (0, _flags["default"])(/x/) !== undefined;
function hasNativeFlag(flag) {
// Can't check based on the presence of properties/getters since browsers might support such
// properties even when they don't support the corresponding flag in regex construction (tested
// in Chrome 48, where `'unicode' in /x/` is true but trying to construct a regex with flag `u`
// throws an error)
var isSupported = true;
try {
// Can't use regex literals for testing even in a `try` because regex literals with
// unsupported flags cause a compilation error in IE
new RegExp('', flag); // Work around a broken/incomplete IE11 polyfill for sticky introduced in core-js 3.6.0
if (flag === 'y') {
// Using function to avoid babel transform to regex literal
var gy = function () {
return 'gy';
}();
var incompleteY = '.a'.replace(new RegExp('a', gy), '.') === '..';
if (incompleteY) {
isSupported = false;
}
}
} catch (exception) {
isSupported = false;
}
return isSupported;
} // Check for ES2021 `d` flag support
var hasNativeD = hasNativeFlag('d'); // Check for ES2018 `s` flag support
var hasNativeS = hasNativeFlag('s'); // Check for ES6 `u` flag support
var hasNativeU = hasNativeFlag('u'); // Check for ES6 `y` flag support
var hasNativeY = hasNativeFlag('y'); // Tracker for known flags, including addon flags
var registeredFlags = {
d: hasNativeD,
g: true,
i: true,
m: true,
s: hasNativeS,
u: hasNativeU,
y: hasNativeY
}; // Flags to remove when passing to native `RegExp` constructor
var nonnativeFlags = hasNativeS ? /[^dgimsuy]+/g : /[^dgimuy]+/g;
/**
* Attaches extended data and `XRegExp.prototype` properties to a regex object.
*
* @private
* @param {RegExp} regex Regex to augment.
* @param {Array} captureNames Array with capture names, or `null`.
* @param {String} xSource XRegExp pattern used to generate `regex`, or `null` if N/A.
* @param {String} xFlags XRegExp flags used to generate `regex`, or `null` if N/A.
* @param {Boolean} [isInternalOnly=false] Whether the regex will be used only for internal
* operations, and never exposed to users. For internal-only regexes, we can improve perf by
* skipping some operations like attaching `XRegExp.prototype` properties.
* @returns {!RegExp} Augmented regex.
*/
function augment(regex, captureNames, xSource, xFlags, isInternalOnly) {
var _context;
regex[REGEX_DATA] = {
captureNames: captureNames
};
if (isInternalOnly) {
return regex;
} // Can't auto-inherit these since the XRegExp constructor returns a nonprimitive value
if (regex.__proto__) {
regex.__proto__ = XRegExp.prototype;
} else {
for (var p in XRegExp.prototype) {
// An `XRegExp.prototype.hasOwnProperty(p)` check wouldn't be worth it here, since this
// is performance sensitive, and enumerable `Object.prototype` or `RegExp.prototype`
// extensions exist on `regex.prototype` anyway
regex[p] = XRegExp.prototype[p];
}
}
regex[REGEX_DATA].source = xSource; // Emulate the ES6 `flags` prop by ensuring flags are in alphabetical order
regex[REGEX_DATA].flags = xFlags ? (0, _sort["default"])(_context = xFlags.split('')).call(_context).join('') : xFlags;
return regex;
}
/**
* Removes any duplicate characters from the provided string.
*
* @private
* @param {String} str String to remove duplicate characters from.
* @returns {string} String with any duplicate characters removed.
*/
function clipDuplicates(str) {
return str.replace(/([\s\S])(?=[\s\S]*\1)/g, '');
}
/**
* Copies a regex object while preserving extended data and augmenting with `XRegExp.prototype`
* properties. The copy has a fresh `lastIndex` property (set to zero). Allows adding and removing
* flags g and y while copying the regex.
*
* @private
* @param {RegExp} regex Regex to copy.
* @param {Object} [options] Options object with optional properties:
* - `addG` {Boolean} Add flag g while copying the regex.
* - `addY` {Boolean} Add flag y while copying the regex.
* - `removeG` {Boolean} Remove flag g while copying the regex.
* - `removeY` {Boolean} Remove flag y while copying the regex.
* - `isInternalOnly` {Boolean} Whether the copied regex will be used only for internal
* operations, and never exposed to users. For internal-only regexes, we can improve perf by
* skipping some operations like attaching `XRegExp.prototype` properties.
* - `source` {String} Overrides `<regex>.source`, for special cases.
* @returns {RegExp} Copy of the provided regex, possibly with modified flags.
*/
function copyRegex(regex, options) {
var _context2;
if (!XRegExp.isRegExp(regex)) {
throw new TypeError('Type RegExp expected');
}
var xData = regex[REGEX_DATA] || {};
var flags = getNativeFlags(regex);
var flagsToAdd = '';
var flagsToRemove = '';
var xregexpSource = null;
var xregexpFlags = null;
options = options || {};
if (options.removeG) {
flagsToRemove += 'g';
}
if (options.removeY) {
flagsToRemove += 'y';
}
if (flagsToRemove) {
flags = flags.replace(new RegExp("[".concat(flagsToRemove, "]+"), 'g'), '');
}
if (options.addG) {
flagsToAdd += 'g';
}
if (options.addY) {
flagsToAdd += 'y';
}
if (flagsToAdd) {
flags = clipDuplicates(flags + flagsToAdd);
}
if (!options.isInternalOnly) {
if (xData.source !== undefined) {
xregexpSource = xData.source;
} // null or undefined; don't want to add to `flags` if the previous value was null, since
// that indicates we're not tracking original precompilation flags
if ((0, _flags["default"])(xData) != null) {
// Flags are only added for non-internal regexes by `XRegExp.globalize`. Flags are never
// removed for non-internal regexes, so don't need to handle it
xregexpFlags = flagsToAdd ? clipDuplicates((0, _flags["default"])(xData) + flagsToAdd) : (0, _flags["default"])(xData);
}
} // Augment with `XRegExp.prototype` properties, but use the native `RegExp` constructor to avoid
// searching for special tokens. That would be wrong for regexes constructed by `RegExp`, and
// unnecessary for regexes constructed by `XRegExp` because the regex has already undergone the
// translation to native regex syntax
regex = augment(new RegExp(options.source || regex.source, flags), hasNamedCapture(regex) ? (0, _slice["default"])(_context2 = xData.captureNames).call(_context2, 0) : null, xregexpSource, xregexpFlags, options.isInternalOnly);
return regex;
}
/**
* Converts hexadecimal to decimal.
*
* @private
* @param {String} hex
* @returns {number}
*/
function dec(hex) {
return (0, _parseInt2["default"])(hex, 16);
}
/**
* Returns a pattern that can be used in a native RegExp in place of an ignorable token such as an
* inline comment or whitespace with flag x. This is used directly as a token handler function
* passed to `XRegExp.addToken`.
*
* @private
* @param {String} match Match arg of `XRegExp.addToken` handler
* @param {String} scope Scope arg of `XRegExp.addToken` handler
* @param {String} flags Flags arg of `XRegExp.addToken` handler
* @returns {string} Either '' or '(?:)', depending on which is needed in the context of the match.
*/
function getContextualTokenSeparator(match, scope, flags) {
var matchEndPos = match.index + match[0].length;
var precedingChar = match.input[match.index - 1];
var followingChar = match.input[matchEndPos];
if ( // No need to separate tokens if at the beginning or end of a group, before or after a
// group, or before or after a `|`
/^[()|]$/.test(precedingChar) || /^[()|]$/.test(followingChar) || // No need to separate tokens if at the beginning or end of the pattern
match.index === 0 || matchEndPos === match.input.length || // No need to separate tokens if at the beginning of a noncapturing group or lookaround.
// Looks only at the last 4 chars (at most) for perf when constructing long regexes.
/\(\?(?:[:=!]|<[=!])$/.test(match.input.substring(match.index - 4, match.index)) || // Avoid separating tokens when the following token is a quantifier
isQuantifierNext(match.input, matchEndPos, flags)) {
return '';
} // Keep tokens separated. This avoids e.g. inadvertedly changing `\1 1` or `\1(?#)1` to `\11`.
// This also ensures all tokens remain as discrete atoms, e.g. it prevents converting the
// syntax error `(? :` into `(?:`.
return '(?:)';
}
/**
* Returns native `RegExp` flags used by a regex object.
*
* @private
* @param {RegExp} regex Regex to check.
* @returns {string} Native flags in use.
*/
function getNativeFlags(regex) {
return hasFlagsProp ? (0, _flags["default"])(regex) : // Explicitly using `RegExp.prototype.toString` (rather than e.g. `String` or concatenation
// with an empty string) allows this to continue working predictably when
// `XRegExp.proptotype.toString` is overridden
/\/([a-z]*)$/i.exec(RegExp.prototype.toString.call(regex))[1];
}
/**
* Determines whether a regex has extended instance data used to track capture names.
*
* @private
* @param {RegExp} regex Regex to check.
* @returns {boolean} Whether the regex uses named capture.
*/
function hasNamedCapture(regex) {
return !!(regex[REGEX_DATA] && regex[REGEX_DATA].captureNames);
}
/**
* Converts decimal to hexadecimal.
*
* @private
* @param {Number|String} dec
* @returns {string}
*/
function hex(dec) {
return (0, _parseInt2["default"])(dec, 10).toString(16);
}
/**
* Checks whether the next nonignorable token after the specified position is a quantifier.
*
* @private
* @param {String} pattern Pattern to search within.
* @param {Number} pos Index in `pattern` to search at.
* @param {String} flags Flags used by the pattern.
* @returns {Boolean} Whether the next nonignorable token is a quantifier.
*/
function isQuantifierNext(pattern, pos, flags) {
var inlineCommentPattern = '\\(\\?#[^)]*\\)';
var lineCommentPattern = '#[^#\\n]*';
var quantifierPattern = '[?*+]|{\\d+(?:,\\d*)?}';
var regex = (0, _indexOf["default"])(flags).call(flags, 'x') !== -1 ? // Ignore any leading whitespace, line comments, and inline comments
/^(?:\s|#[^#\n]*|\(\?#[^)]*\))*(?:[?*+]|{\d+(?:,\d*)?})/ : // Ignore any leading inline comments
/^(?:\(\?#[^)]*\))*(?:[?*+]|{\d+(?:,\d*)?})/;
return regex.test((0, _slice["default"])(pattern).call(pattern, pos));
}
/**
* Determines whether a value is of the specified type, by resolving its internal [[Class]].
*
* @private
* @param {*} value Object to check.
* @param {String} type Type to check for, in TitleCase.
* @returns {boolean} Whether the object matches the type.
*/
function isType(value, type) {
return Object.prototype.toString.call(value) === "[object ".concat(type, "]");
}
/**
* Returns the object, or throws an error if it is `null` or `undefined`. This is used to follow
* the ES5 abstract operation `ToObject`.
*
* @private
* @param {*} value Object to check and return.
* @returns {*} The provided object.
*/
function nullThrows(value) {
// null or undefined
if (value == null) {
throw new TypeError('Cannot convert null or undefined to object');
}
return value;
}
/**
* Adds leading zeros if shorter than four characters. Used for fixed-length hexadecimal values.
*
* @private
* @param {String} str
* @returns {string}
*/
function pad4(str) {
while (str.length < 4) {
str = "0".concat(str);
}
return str;
}
/**
* Checks for flag-related errors, and strips/applies flags in a leading mode modifier. Offloads
* the flag preparation logic from the `XRegExp` constructor.
*
* @private
* @param {String} pattern Regex pattern, possibly with a leading mode modifier.
* @param {String} flags Any combination of flags.
* @returns {!Object} Object with properties `pattern` and `flags`.
*/
function prepareFlags(pattern, flags) {
// Recent browsers throw on duplicate flags, so copy this behavior for nonnative flags
if (clipDuplicates(flags) !== flags) {
throw new SyntaxError("Invalid duplicate regex flag ".concat(flags));
} // Strip and apply a leading mode modifier with any combination of flags except `dgy`
pattern = pattern.replace(/^\(\?([\w$]+)\)/, function ($0, $1) {
if (/[dgy]/.test($1)) {
throw new SyntaxError("Cannot use flags dgy in mode modifier ".concat($0));
} // Allow duplicate flags within the mode modifier
flags = clipDuplicates(flags + $1);
return '';
}); // Throw on unknown native or nonnative flags
var _iterator = _createForOfIteratorHelper(flags),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var flag = _step.value;
if (!registeredFlags[flag]) {
throw new SyntaxError("Unknown regex flag ".concat(flag));
}
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
return {
pattern: pattern,
flags: flags
};
}
/**
* Prepares an options object from the given value.
*
* @private
* @param {String|Object} value Value to convert to an options object.
* @returns {Object} Options object.
*/
function prepareOptions(value) {
var options = {};
if (isType(value, 'String')) {
(0, _forEach["default"])(XRegExp).call(XRegExp, value, /[^\s,]+/, function (match) {
options[match] = true;
});
return options;
}
return value;
}
/**
* Registers a flag so it doesn't throw an 'unknown flag' error.
*
* @private
* @param {String} flag Single-character flag to register.
*/
function registerFlag(flag) {
if (!/^[\w$]$/.test(flag)) {
throw new Error('Flag must be a single character A-Za-z0-9_$');
}
registeredFlags[flag] = true;
}
/**
* Runs built-in and custom regex syntax tokens in reverse insertion order at the specified
* position, until a match is found.
*
* @private
* @param {String} pattern Original pattern from which an XRegExp object is being built.
* @param {String} flags Flags being used to construct the regex.
* @param {Number} pos Position to search for tokens within `pattern`.
* @param {Number} scope Regex scope to apply: 'default' or 'class'.
* @param {Object} context Context object to use for token handler functions.
* @returns {Object} Object with properties `matchLength`, `output`, and `reparse`; or `null`.
*/
function runTokens(pattern, flags, pos, scope, context) {
var i = tokens.length;
var leadChar = pattern[pos];
var result = null;
var match;
var t; // Run in reverse insertion order
while (i--) {
t = tokens[i];
if (t.leadChar && t.leadChar !== leadChar || t.scope !== scope && t.scope !== 'all' || t.flag && !((0, _indexOf["default"])(flags).call(flags, t.flag) !== -1)) {
continue;
}
match = XRegExp.exec(pattern, t.regex, pos, 'sticky');
if (match) {
result = {
matchLength: match[0].length,
output: t.handler.call(context, match, scope, flags),
reparse: t.reparse
}; // Finished with token tests
break;
}
}
return result;
}
/**
* Enables or disables implicit astral mode opt-in. When enabled, flag A is automatically added to
* all new regexes created by XRegExp. This causes an error to be thrown when creating regexes if
* the Unicode Base addon is not available, since flag A is registered by that addon.
*
* @private
* @param {Boolean} on `true` to enable; `false` to disable.
*/
function setAstral(on) {
features.astral = on;
}
/**
* Adds named capture groups to the `groups` property of match arrays. See here for details:
* https://github.com/tc39/proposal-regexp-named-groups
*
* @private
* @param {Boolean} on `true` to enable; `false` to disable.
*/
function setNamespacing(on) {
features.namespacing = on;
} // ==--------------------------==
// Constructor
// ==--------------------------==
/**
* Creates an extended regular expression object for matching text with a pattern. Differs from a
* native regular expression in that additional syntax and flags are supported. The returned object
* is in fact a native `RegExp` and works with all native methods.
*
* @class XRegExp
* @constructor
* @param {String|RegExp} pattern Regex pattern string, or an existing regex object to copy.
* @param {String} [flags] Any combination of flags.
* Native flags:
* - `d` - indices for capturing groups (ES2021)
* - `g` - global
* - `i` - ignore case
* - `m` - multiline anchors
* - `u` - unicode (ES6)
* - `y` - sticky (Firefox 3+, ES6)
* Additional XRegExp flags:
* - `n` - named capture only
* - `s` - dot matches all (aka singleline) - works even when not natively supported
* - `x` - free-spacing and line comments (aka extended)
* - `A` - 21-bit Unicode properties (aka astral) - requires the Unicode Base addon
* Flags cannot be provided when constructing one `RegExp` from another.
* @returns {RegExp} Extended regular expression object.
* @example
*
* // With named capture and flag x
* XRegExp(`(?<year> [0-9]{4} ) -? # year
* (?<month> [0-9]{2} ) -? # month
* (?<day> [0-9]{2} ) # day`, 'x');
*
* // Providing a regex object copies it. Native regexes are recompiled using native (not XRegExp)
* // syntax. Copies maintain extended data, are augmented with `XRegExp.prototype` properties, and
* // have fresh `lastIndex` properties (set to zero).
* XRegExp(/regex/);
*/
function XRegExp(pattern, flags) {
if (XRegExp.isRegExp(pattern)) {
if (flags !== undefined) {
throw new TypeError('Cannot supply flags when copying a RegExp');
}
return copyRegex(pattern);
} // Copy the argument behavior of `RegExp`
pattern = pattern === undefined ? '' : String(pattern);
flags = flags === undefined ? '' : String(flags);
if (XRegExp.isInstalled('astral') && !((0, _indexOf["default"])(flags).call(flags, 'A') !== -1)) {
// This causes an error to be thrown if the Unicode Base addon is not available
flags += 'A';
}
if (!patternCache[pattern]) {
patternCache[pattern] = {};
}
if (!patternCache[pattern][flags]) {
var context = {
hasNamedCapture: false,
captureNames: []
};
var scope = defaultScope;
var output = '';
var pos = 0;
var result; // Check for flag-related errors, and strip/apply flags in a leading mode modifier
var applied = prepareFlags(pattern, flags);
var appliedPattern = applied.pattern;
var appliedFlags = (0, _flags["default"])(applied); // Use XRegExp's tokens to translate the pattern to a native regex pattern.
// `appliedPattern.length` may change on each iteration if tokens use `reparse`
while (pos < appliedPattern.length) {
do {
// Check for custom tokens at the current position
result = runTokens(appliedPattern, appliedFlags, pos, scope, context); // If the matched token used the `reparse` option, splice its output into the
// pattern before running tokens again at the same position
if (result && result.reparse) {
appliedPattern = (0, _slice["default"])(appliedPattern).call(appliedPattern, 0, pos) + result.output + (0, _slice["default"])(appliedPattern).call(appliedPattern, pos + result.matchLength);
}
} while (result && result.reparse);
if (result) {
output += result.output;
pos += result.matchLength || 1;
} else {
// Get the native token at the current position
var _XRegExp$exec = XRegExp.exec(appliedPattern, nativeTokens[scope], pos, 'sticky'),
_XRegExp$exec2 = (0, _slicedToArray2["default"])(_XRegExp$exec, 1),
token = _XRegExp$exec2[0];
output += token;
pos += token.length;
if (token === '[' && scope === defaultScope) {
scope = classScope;
} else if (token === ']' && scope === classScope) {
scope = defaultScope;
}
}
}
patternCache[pattern][flags] = {
// Use basic cleanup to collapse repeated empty groups like `(?:)(?:)` to `(?:)`. Empty
// groups are sometimes inserted during regex transpilation in order to keep tokens
// separated. However, more than one empty group in a row is never needed.
pattern: output.replace(/(?:\(\?:\))+/g, '(?:)'),
// Strip all but native flags
flags: appliedFlags.replace(nonnativeFlags, ''),
// `context.captureNames` has an item for each capturing group, even if unnamed
captures: context.hasNamedCapture ? context.captureNames : null
};
}
var generated = patternCache[pattern][flags];
return augment(new RegExp(generated.pattern, (0, _flags["default"])(generated)), generated.captures, pattern, flags);
} // Add `RegExp.prototype` to the prototype chain
XRegExp.prototype = /(?:)/; // ==--------------------------==
// Public properties
// ==--------------------------==
/**
* The XRegExp version number as a string containing three dot-separated parts. For example,
* '2.0.0-beta-3'.
*
* @static
* @memberOf XRegExp
* @type String
*/
XRegExp.version = '5.1.1'; // ==--------------------------==
// Public methods
// ==--------------------------==
// Intentionally undocumented; used in tests and addons
XRegExp._clipDuplicates = clipDuplicates;
XRegExp._hasNativeFlag = hasNativeFlag;
XRegExp._dec = dec;
XRegExp._hex = hex;
XRegExp._pad4 = pad4;
/**
* Extends XRegExp syntax and allows custom flags. This is used internally and can be used to
* create XRegExp addons. If more than one token can match the same string, the last added wins.
*
* @memberOf XRegExp
* @param {RegExp} regex Regex object that matches the new token.
* @param {Function} handler Function that returns a new pattern string (using native regex syntax)
* to replace the matched token within all future XRegExp regexes. Has access to persistent
* properties of the regex being built, through `this`. Invoked with three arguments:
* - The match array, with named backreference properties.
* - The regex scope where the match was found: 'default' or 'class'.
* - The flags used by the regex, including any flags in a leading mode modifier.
* The handler function becomes part of the XRegExp construction process, so be careful not to
* construct XRegExps within the function or you will trigger infinite recursion.
* @param {Object} [options] Options object with optional properties:
* - `scope` {String} Scope where the token applies: 'default', 'class', or 'all'.
* - `flag` {String} Single-character flag that triggers the token. This also registers the
* flag, which prevents XRegExp from throwing an 'unknown flag' error when the flag is used.
* - `optionalFlags` {String} Any custom flags checked for within the token `handler` that are
* not required to trigger the token. This registers the flags, to prevent XRegExp from
* throwing an 'unknown flag' error when any of the flags are used.
* - `reparse` {Boolean} Whether the `handler` function's output should not be treated as
* final, and instead be reparseable by other tokens (including the current token). Allows
* token chaining or deferring.
* - `leadChar` {String} Single character that occurs at the beginning of any successful match
* of the token (not always applicable). This doesn't change the behavior of the token unless
* you provide an erroneous value. However, providing it can increase the token's performance
* since the token can be skipped at any positions where this character doesn't appear.
* @example
*
* // Basic usage: Add \a for the ALERT control code
* XRegExp.addToken(
* /\\a/,
* () => '\\x07',
* {scope: 'all'}
* );
* XRegExp('\\a[\\a-\\n]+').test('\x07\n\x07'); // -> true
*
* // Add the U (ungreedy) flag from PCRE and RE2, which reverses greedy and lazy quantifiers.
* // Since `scope` is not specified, it uses 'default' (i.e., transformations apply outside of
* // character classes only)
* XRegExp.addToken(
* /([?*+]|{\d+(?:,\d*)?})(\??)/,
* (match) => `${match[1]}${match[2] ? '' : '?'}`,
* {flag: 'U'}
* );
* XRegExp('a+', 'U').exec('aaa')[0]; // -> 'a'
* XRegExp('a+?', 'U').exec('aaa')[0]; // -> 'aaa'
*/
XRegExp.addToken = function (regex, handler, options) {
options = options || {};
var _options = options,
optionalFlags = _options.optionalFlags;
if (options.flag) {
registerFlag(options.flag);
}
if (optionalFlags) {
optionalFlags = optionalFlags.split('');
var _iterator2 = _createForOfIteratorHelper(optionalFlags),
_step2;
try {
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
var flag = _step2.value;
registerFlag(flag);
}
} catch (err) {
_iterator2.e(err);
} finally {
_iterator2.f();
}
} // Add to the private list of syntax tokens
tokens.push({
regex: copyRegex(regex, {
addG: true,
addY: hasNativeY,
isInternalOnly: true
}),
handler: handler,
scope: options.scope || defaultScope,
flag: options.flag,
reparse: options.reparse,
leadChar: options.leadChar
}); // Reset the pattern cache used by the `XRegExp` constructor, since the same pattern and flags
// might now produce different results
XRegExp.cache.flush('patterns');
};
/**
* Caches and returns the result of calling `XRegExp(pattern, flags)`. On any subsequent call with
* the same pattern and flag combination, the cached copy of the regex is returned.
*
* @memberOf XRegExp
* @param {String} pattern Regex pattern string.
* @param {String} [flags] Any combination of XRegExp flags.
* @returns {RegExp} Cached XRegExp object.
* @example
*
* let match;
* while (match = XRegExp.cache('.', 'gs').exec('abc')) {
* // The regex is compiled once only
* }
*/
XRegExp.cache = function (pattern, flags) {
if (!regexCache[pattern]) {
regexCache[pattern] = {};
}
return regexCache[pattern][flags] || (regexCache[pattern][flags] = XRegExp(pattern, flags));
}; // Intentionally undocumented; used in tests
XRegExp.cache.flush = function (cacheName) {
if (cacheName === 'patterns') {
// Flush the pattern cache used by the `XRegExp` constructor
patternCache = {};
} else {
// Flush the regex cache populated by `XRegExp.cache`
regexCache = {};
}
};
/**
* Escapes any regular expression metacharacters, for use when matching literal strings. The result
* can safely be used at any position within a regex that uses any flags.
*
* @memberOf XRegExp
* @param {String} str String to escape.
* @returns {string} String with regex metacharacters escaped.
* @example
*
* XRegExp.escape('Escaped? <.>');
* // -> 'Escaped\?\u0020<\.>'
*/
// Following are the contexts where each metacharacter needs to be escaped because it would
// otherwise have a special meaning, change the meaning of surrounding characters, or cause an
// error. Context 'default' means outside character classes only.
// - `\` - context: all
// - `[()*+?.$|` - context: default
// - `]` - context: default with flag u or if forming the end of a character class
// - `{}` - context: default with flag u or if part of a valid/complete quantifier pattern
// - `,` - context: default if in a position that causes an unescaped `{` to turn into a quantifier.
// Ex: `/^a{1\,2}$/` matches `'a{1,2}'`, but `/^a{1,2}$/` matches `'a'` or `'aa'`
// - `#` and <whitespace> - context: default with flag x
// - `^` - context: default, and context: class if it's the first character in the class
// - `-` - context: class if part of a valid character class range
XRegExp.escape = function (str) {
return String(nullThrows(str)). // Escape most special chars with a backslash
replace(/[\\\[\]{}()*+?.^$|]/g, '\\$&'). // Convert to \uNNNN for special chars that can't be escaped when used with ES6 flag `u`
replace(/[\s#\-,]/g, function (match) {
return "\\u".concat(pad4(hex(match.charCodeAt(0))));
});
};
/**
* Executes a regex search in a specified string. Returns a match array or `null`. If the provided
* regex uses named capture, named capture properties are included on the match array's `groups`
* property. Optional `pos` and `sticky` arguments specify the search start position, and whether
* the match must start at the specified position only. The `lastIndex` property of the provided
* regex is not used, but is updated for compatibility. Also fixes browser bugs compared to the
* native `RegExp.prototype.exec` and can be used reliably cross-browser.
*
* @memberOf XRegExp
* @param {String} str String to search.
* @param {RegExp} regex Regex to search with.
* @param {Number} [pos=0] Zero-based index at which to start the search.
* @param {Boolean|String} [sticky=false] Whether the match must start at the specified position
* only. The string `'sticky'` is accepted as an alternative to `true`.
* @returns {Array} Match array with named capture properties on the `groups` object, or `null`. If
* the `namespacing` feature is off, named capture properties are directly on the match array.
* @example
*
* // Basic use, with named capturing group
* let match = XRegExp.exec('U+2620', XRegExp('U\\+(?<hex>[0-9A-F]{4})'));
* match.groups.hex; // -> '2620'
*
* // With pos and sticky, in a loop
* let pos = 3, result = [], match;
* while (match = XRegExp.exec('<1><2><3><4>5<6>', /<(\d)>/, pos, 'sticky')) {
* result.push(match[1]);
* pos = match.index + match[0].length;
* }
* // result -> ['2', '3', '4']
*/
XRegExp.exec = function (str, regex, pos, sticky) {
var cacheKey = 'g';
var addY = false;
var fakeY = false;
var match;
addY = hasNativeY && !!(sticky || regex.sticky && sticky !== false);
if (addY) {
cacheKey += 'y';
} else if (sticky) {
// Simulate sticky matching by appending an empty capture to the original regex. The
// resulting regex will succeed no matter what at the current index (set with `lastIndex`),
// and will not search the rest of the subject string. We'll know that the original regex
// has failed if that last capture is `''` rather than `undefined` (i.e., if that last
// capture participated in the match).
fakeY = true;
cacheKey += 'FakeY';
}
regex[REGEX_DATA] = regex[REGEX_DATA] || {}; // Shares cached copies with `XRegExp.match`/`replace`
var r2 = regex[REGEX_DATA][cacheKey] || (regex[REGEX_DATA][cacheKey] = copyRegex(regex, {
addG: true,
addY: addY,
source: fakeY ? "".concat(regex.source, "|()") : undefined,
removeY: sticky === false,
isInternalOnly: true
}));
pos = pos || 0;
r2.lastIndex = pos; // Fixed `exec` required for `lastIndex` fix, named backreferences, etc.
match = fixed.exec.call(r2, str); // Get rid of the capture added by the pseudo-sticky matcher if needed. An empty string means
// the original regexp failed (see above).
if (fakeY && match && match.pop() === '') {
match = null;
}
if (regex.global) {
regex.lastIndex = match ? r2.lastIndex : 0;
}
return match;
};
/**
* Executes a provided function once per regex match. Searches always start at the beginning of the
* string and continue until the end, regardless of the state of the regex's `global` property and
* initial `lastIndex`.
*
* @memberOf XRegExp
* @param {String} str String to search.
* @param {RegExp} regex Regex to search with.
* @param {Function} callback Function to execute for each match. Invoked with four arguments:
* - The match array, with named backreference properties.
* - The zero-based match index.
* - The string being traversed.
* - The regex object being used to traverse the string.
* @example
*
* // Extracts every other digit from a string
* const evens = [];
* XRegExp.forEach('1a2345', /\d/, (match, i) => {
* if (i % 2) evens.push(+match[0]);
* });
* // evens -> [2, 4]
*/
XRegExp.forEach = function (str, regex, callback) {
var pos = 0;
var i = -1;
var match;
while (match = XRegExp.exec(str, regex, pos)) {
// Because `regex` is provided to `callback`, the function could use the deprecated/
// nonstandard `RegExp.prototype.compile` to mutate the regex. However, since `XRegExp.exec`
// doesn't use `lastIndex` to set the search position, this can't lead to an infinite loop,
// at least. Actually, because of the way `XRegExp.exec` caches globalized versions of
// regexes, mutating the regex will not have any effect on the iteration or matched strings,
// which is a nice side effect that brings extra safety.
callback(match, ++i, str, regex);
pos = match.index + (match[0].length || 1);
}
};
/**
* Copies a regex object and adds flag `g`. The copy maintains extended data, is augmented with
* `XRegExp.prototype` properties, and has a fresh `lastIndex` property (set to zero). Native
* regexes are not recompiled using XRegExp syntax.
*
* @memberOf XRegExp
* @param {RegExp} regex Regex to globalize.
* @returns {RegExp} Copy of the provided regex with flag `g` added.
* @example
*
* const globalCopy = XRegExp.globalize(/regex/);
* globalCopy.global; // -> true
*/
XRegExp.globalize = function (regex) {
return copyRegex(regex, {
addG: true
});
};
/**
* Installs optional features according to the specified options. Can be undone using
* `XRegExp.uninstall`.
*
* @memberOf XRegExp
* @param {Object|String} options Options object or string.
* @example
*
* // With an options object
* XRegExp.install({
* // Enables support for astral code points in Unicode addons (implicitly sets flag A)
* astral: true,
*
* // Adds named capture groups to the `groups` property of matches
* namespacing: true
* });
*
* // With an options string
* XRegExp.install('astral namespacing');
*/
XRegExp.install = function (options) {
options = prepareOptions(options);
if (!features.astral && options.astral) {
setAstral(true);
}
if (!features.namespacing && options.namespacing) {
setNamespacing(true);
}
};
/**
* Checks whether an individual optional feature is installed.
*
* @memberOf XRegExp
* @param {String} feature Name of the feature to check. One of:
* - `astral`
* - `namespacing`
* @returns {boolean} Whether the feature is installed.
* @example
*
* XRegExp.isInstalled('astral');
*/
XRegExp.isInstalled = function (feature) {
return !!features[feature];
};
/**
* Returns `true` if an object is a regex; `false` if it isn't. This works correctly for regexes
* created in another frame, when `instanceof` and `constructor` checks would fail.
*
* @memberOf XRegExp
* @param {*} value Object to check.
* @returns {boolean} Whether the object is a `RegExp` object.
* @example
*
* XRegExp.isRegExp('string'); // -> false
* XRegExp.isRegExp(/regex/i); // -> true
* XRegExp.isRegExp(RegExp('^', 'm')); // -> true
* XRegExp.isRegExp(XRegExp('(?s).')); // -> true
*/
XRegExp.isRegExp = function (value) {
return Object.prototype.toString.call(value) === '[object RegExp]';
}; // Same as `isType(value, 'RegExp')`, but avoiding that function call here for perf since
// `isRegExp` is used heavily by internals including regex construction
/**
* Returns the first matched string, or in global mode, an array containing all matched strings.
* This is essentially a more convenient re-implementation of `String.prototype.match` that gives
* the result types you actually want (string instead of `exec`-style array in match-first mode,
* and an empty array instead of `null` when no matches are found in match-all mode). It also lets
* you override flag g and ignore `lastIndex`, and fixes browser bugs.
*
* @memberOf XRegExp
* @param {String} str String to search.
* @param {RegExp} regex Regex to search with.
* @param {String} [scope='one'] Use 'one' to return the first match as a string. Use 'all' to
* return an array of all matched strings. If not explicitly specified and `regex` uses flag g,
* `scope` is 'all'.
* @returns {String|Array} In match-first mode: First match as a string, or `null`. In match-all
* mode: Array of all matched strings, or an empty array.
* @example
*
* // Match first
* XRegExp.match('abc', /\w/); // -> 'a'
* XRegExp.match('abc', /\w/g, 'one'); // -> 'a'
* XRegExp.match('abc', /x/g, 'one'); // -> null
*
* // Match all
* XRegExp.match('abc', /\w/g); // -> ['a', 'b', 'c']
* XRegExp.match('abc', /\w/, 'all'); // -> ['a', 'b', 'c']
* XRegExp.match('abc', /x/, 'all'); // -> []
*/
XRegExp.match = function (str, regex, scope) {
var global = regex.global && scope !== 'one' || scope === 'all';
var cacheKey = (global ? 'g' : '') + (regex.sticky ? 'y' : '') || 'noGY';
regex[REGEX_DATA] = regex[REGEX_DATA] || {}; // Shares cached copies with `XRegExp.exec`/`replace`
var r2 = regex[REGEX_DATA][cacheKey] || (regex[REGEX_DATA][cacheKey] = copyRegex(regex, {
addG: !!global,
removeG: scope === 'one',
isInternalOnly: true
}));
var result = String(nullThrows(str)).match(r2);
if (regex.global) {
regex.lastIndex = scope === 'one' && result ? // Can't use `r2.lastIndex` since `r2` is nonglobal in this case
result.index + result[0].length : 0;
}
return global ? result || [] : result && result[0];
};
/**
* Retrieves the matches from searching a string using a chain of regexes that successively search
* within previous matches. The provided `chain` array can contain regexes and or objects with
* `regex` and `backref` properties. When a backreference is specified, the named or numbered
* backreference is passed forward to the next regex or returned.
*
* @memberOf XRegExp
* @param {String} str String to search.
* @param {Array} chain Regexes that each search for matches within preceding results.
* @returns {Array} Matches by the last regex in the chain, or an empty array.
* @example
*
* // Basic usage; matches numbers within <b> tags
* XRegExp.matchChain('1 <b>2</b> 3 <b>4 a 56</b>', [
* XRegExp('(?is)<b>.*?</b>'),
* /\d+/
* ]);
* // -> ['2', '4', '56']
*
* // Passing forward and returning specific backreferences
* const html = `<a href="http://xregexp.com/api/">XRegExp</a>
* <a href="http://www.google.com/">Google</a>`;
* XRegExp.matchChain(html, [
* {regex: /<a href="([^"]+)">/i, backref: 1},
* {regex: XRegExp('(?i)^https?://(?<domain>[^/?#]+)'), backref: 'domain'}
* ]);
* // -> ['xregexp.com', 'www.google.com']
*/
XRegExp.matchChain = function (str, chain) {
return function recurseChain(values, level) {
var item = chain[level].regex ? chain[level] : {
regex: chain[level]
};
var matches = [];
function addMatch(match) {
if (item.backref) {
var ERR_UNDEFINED_GROUP = "Backreference to undefined group: ".concat(item.backref);
var isNamedBackref = isNaN(item.backref);
if (isNamedBackref && XRegExp.isInstalled('namespacing')) {
// `groups` has `null` as prototype, so using `in` instead of `hasOwnProperty`
if (!(match.groups && item.backref in match.groups)) {
throw new ReferenceError(ERR_UNDEFINED_GROUP);
}
} else if (!match.hasOwnProperty(item.backref)) {
throw new ReferenceError(ERR_UNDEFINED_GROUP);
}
var backrefValue = isNamedBackref && XRegExp.isInstalled('namespacing') ? match.groups[item.backref] : match[item.backref];
matches.push(backrefValue || '');
} else {
matches.push(match[0]);
}
}
var _iterator3 = _createForOfIteratorHelper(values),
_step3;
try {
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
var value = _step3.value;
(0, _forEach["default"])(XRegExp).call(XRegExp, value, item.regex, addMatch);
}
} catch (err) {
_iterator3.e(err);
} finally {
_iterator3.f();
}
return level === chain.length - 1 || !matches.length ? matches : recurseChain(matches, level + 1);
}([str], 0);
};
/**
* Returns a new string with one or all matches of a pattern replaced. The pattern can be a string
* or regex, and the replacement can be a string or a function to be called for each match. To
* perform a global search and replace, use the optional `scope` argument or include flag g if using
* a regex. Replacement strings can use `$<n>` or `${n}` for named and numbered backreferences.
* Replacement functions can use named backreferences via the last argument. Also fixes browser bugs
* compared to the native `String.prototype.replace` and can be used reliably cross-browser.
*
* @memberOf XRegExp
* @param {String} str String to search.
* @param {RegExp|String} search Search pattern to be replaced.
* @param {String|Function} replacement Replacement string or a function invoked to create it.
* Replacement strings can include special replacement syntax:
* - $$ - Inserts a literal $ character.
* - $&, $0 - Inserts the matched substring.
* - $` - Inserts the string that precedes the matched substring (left context).
* - $' - Inserts the string that follows the matched substring (right context).
* - $n, $nn - Where n/nn are digits referencing an existing capturing group, inserts
* backreference n/nn.
* - $<n>, ${n} - Where n is a name or any number of digits that reference an existing capturing
* group, inserts backreference n.
* Replacement functions are invoked with three or more arguments:
* - args[0] - The matched substring (corresponds to `$&` above). If the `namespacing` feature
* is off, named backreferences are accessible as properties of this argument.
* - args[1..n] - One argument for each backreference (corresponding to `$1`, `$2`, etc. above).
* If the regex has no capturing groups, no arguments appear in this position.
* - args[n+1] - The zero-based index of the match within the entire search string.
* - args[n+2] - The total string being searched.
* - args[n+3] - If the the search pattern is a regex with named capturing groups, the last
* argument is the groups object. Its keys are the backreference names and its values are the
* backreference values. If the `namespacing` feature is off, this argument is not present.
* @param {String} [scope] Use 'one' to replace the first match only, or 'all'. Defaults to 'one'.
* Defaults to 'all' if using a regex with flag g.
* @returns {String} New string with one or all matches replaced.
* @example
*
* // Regex search, using named backreferences in replacement string
* const name = XRegExp('(?<first>\\w+) (?<last>\\w+)');
* XRegExp.replace('John Smith', name, '$<last>, $<first>');
* // -> 'Smith, John'
*
* // Regex search, using named backreferences in replacement function
* XRegExp.replace('John Smith', name, (...args) => {
* const groups = args[args.length - 1];
* return `${groups.last}, ${groups.first}`;
* });
* // -> 'Smith, John'
*
* // String search, with replace-all
* XRegExp.replace('RegExp builds RegExps', 'RegExp', 'XRegExp', 'all');
* // -> 'XRegExp builds XRegExps'
*/
XRegExp.replace = function (str, search, replacement, scope) {
var isRegex = XRegExp.isRegExp(search);
var global = search.global && scope !== 'one' || scope === 'all';
var cacheKey = (global ? 'g' : '') + (search.sticky ? 'y' : '') || 'noGY';
var s2 = search;
if (isRegex) {
search[REGEX_DATA] = search[REGEX_DATA] || {}; // Shares cached copies with `XRegExp.exec`/`match`. Since a copy is used, `search`'s
// `lastIndex` isn't updated *during* replacement iterations
s2 = search[REGEX_DATA][cacheKey] || (search[REGEX_DATA][cacheKey] = copyRegex(search, {
addG: !!global,
removeG: scope === 'one',
isInternalOnly: true
}));
} else if (global) {
s2 = new RegExp(XRegExp.escape(String(search)), 'g');
} // Fixed `replace` required for named backreferences, etc.
var result = fixed.replace.call(nullThrows(str), s2, replacement);
if (isRegex && search.global) {
// Fixes IE, Safari bug (last tested IE 9, Safari 5.1)
search.lastIndex = 0;
}
return result;
};
/**
* Performs batch processing of string replacements. Used like `XRegExp.replace`, but accepts an
* array of replacement details. Later replacements operate on the output of earlier replacements.
* Replacement details are accepted as an array with a regex or string to search for, the
* replacement string or function, and an optional scope of 'one' or 'all'. Uses the XRegExp
* replacement text syntax, which supports named backreference properties via `$<name>` or
* `${name}`.
*
* @memberOf XRegExp
* @param {String} str String to search.
* @param {Array} replacements Array of replacement detail arrays.
* @returns {String} New string with all replacements.
* @example
*
* str = XRegExp.replaceEach(str, [
* [XRegExp('(?<name>a)'), 'z$<name>'],
* [/b/gi, 'y'],
* [/c/g, 'x', 'one'], // scope 'one' overrides /g
* [/d/, 'w', 'all'], // scope 'all' overrides lack of /g
* ['e', 'v', 'all'], // scope 'all' allows replace-all for strings
* [/f/g, (match) => match.toUpperCase()]
* ]);
*/
XRegExp.replaceEach = function (str, replacements) {
var _iterator4 = _createForOfIteratorHelper(replacements),
_step4;
try {
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
var r = _step4.value;
str = XRegExp.replace(str, r[0], r[1], r[2]);
}
} catch (err) {
_iterator4.e(err);
} finally {
_iterator4.f();
}
return str;
};
/**
* Splits a string into an array of strings using a regex or string separator. Matches of the
* separator are not included in the result array. However, if `separator` is a regex that contains
* capturing groups, backreferences are spliced into the result each time `separator` is matched.
* Fixes browser bugs compared to the native `String.prototype.split` and can be used reliably
* cross-browser.
*
* @memberOf XRegExp
* @param {String} str String to split.
* @param {RegExp|String} separator Regex or string to use for separating the string.
* @param {Number} [limit] Maximum number of items to include in the result array.
* @returns {Array} Array of substrings.
* @example
*
* // Basic use
* XRegExp.split('a b c', ' ');
* // -> ['a', 'b', 'c']
*
* // With limit
* XRegExp.split('a b c', ' ', 2);
* // -> ['a', 'b']
*
* // Backreferences in result array
* XRegExp.split('..word1..', /([a-z]+)(\d+)/i);
* // -> ['..', 'word', '1', '..']
*/
XRegExp.split = function (str, separator, limit) {
return fixed.split.call(nullThrows(str), separator, limit);
};
/**
* Executes a regex search in a specified string. Returns `true` or `false`. Optional `pos` and
* `sticky` arguments specify the search start position, and whether the match must start at the
* specified position only. The `lastIndex` property of the provided regex is not used, but is
* updated for compatibility. Also fixes browser bugs compared to the native
* `RegExp.prototype.test` and can be used reliably cross-browser.
*
* @memberOf XRegExp
* @param {String} str String to search.
* @param {RegExp} regex Regex to search with.
* @param {Number} [pos=0] Zero-based index at which to start the search.
* @param {Boolean|String} [sticky=false] Whether the match must start at the specified position
* only. The string `'sticky'` is accepted as an alternative to `true`.
* @returns {boolean} Whether the regex matched the provided value.
* @example
*
* // Basic use
* XRegExp.test('abc', /c/); // -> true
*
* // With pos and sticky
* XRegExp.test('abc', /c/, 0, 'sticky'); // -> false
* XRegExp.test('abc', /c/, 2, 'sticky'); // -> true
*/
// Do this the easy way :-)
XRegExp.test = function (str, regex, pos, sticky) {
return !!XRegExp.exec(str, regex, pos, sticky);
};
/**
* Uninstalls optional features according to the specified options. Used to undo the actions of
* `XRegExp.install`.
*
* @memberOf XRegExp
* @param {Object|String} options Options object or string.
* @example
*
* // With an options object
* XRegExp.uninstall({
* // Disables support for astral code points in Unicode addons (unless enabled per regex)
* astral: true,
*
* // Don't add named capture groups to the `groups` property of matches
* namespacing: true
* });
*
* // With an options string
* XRegExp.uninstall('astral namespacing');
*/
XRegExp.uninstall = function (options) {
options = prepareOptions(options);
if (features.astral && options.astral) {
setAstral(false);
}
if (features.namespacing && options.namespacing) {
setNamespacing(false);
}
};
/**
* 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
*/
XRegExp.union = function (patterns, flags, options) {
options = options || {};
var conjunction = options.conjunction || 'or';
var numCaptures = 0;
var numPriorCaptures;
var captureNames;
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 "(?<".concat(name, ">");
} // Backreference
} else if (backref) {
// Rewrite the backreference
return "\\".concat(+backref + numPriorCaptures);
}
return match;
}
if (!(isType(patterns, 'Array') && patterns.length)) {
throw new TypeError('Must provide a nonempty array of patterns to merge');
}
var parts = /(\()(?!\?)|\\([1-9]\d*)|\\[\s\S]|\[(?:[^\\\]]|\\[\s\S])*\]/g;
var output = [];
var _iterator5 = _createForOfIteratorHelper(patterns),
_step5;
try {
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
var pattern = _step5.value;
if (XRegExp.isRegExp(pattern)) {
numPriorCaptures = numCaptures;
captureNames = pattern[REGEX_DATA] && pattern[REGEX_DATA].captureNames || []; // Rewrite backreferences. Passing to XRegExp dies on octals and ensures patterns are
// independently valid; helps keep this simple. Named captures are put back
output.push(XRegExp(pattern.source).source.replace(parts, rewrite));
} else {
output.push(XRegExp.escape(pattern));
}
}
} catch (err) {
_iterator5.e(err);
} finally {
_iterator5.f();
}
var separator = conjunction === 'none' ? '' : '|';
return XRegExp(output.join(separator), flags);
}; // ==--------------------------==
// Fixed/extended native methods
// ==--------------------------==
/**
* Adds named capture support (with backreferences returned as `result.name`), and fixes browser
* bugs in the native `RegExp.prototype.exec`. Use via `XRegExp.exec`.
*
* @memberOf RegExp
* @param {String} str String to search.
* @returns {Array} Match array with named backreference properties, or `null`.
*/
fixed.exec = function (str) {
var origLastIndex = this.lastIndex;
var match = RegExp.prototype.exec.apply(this, arguments);
if (match) {
// Fix browsers whose `exec` methods don't return `undefined` for nonparticipating capturing
// groups. This fixes IE 5.5-8, but not IE 9's quirks mode or emulation of older IEs. IE 9
// in standards mode follows the spec.
if (!correctExecNpcg && match.length > 1 && (0, _indexOf["default"])(match).call(match, '') !== -1) {
var _context3;
var r2 = copyRegex(this, {
removeG: true,
isInternalOnly: true
}); // Using `str.slice(match.index)` rather than `match[0]` in case lookahead allowed
// matching due to characters outside the match
(0, _slice["default"])(_context3 = String(str)).call(_context3, match.index).replace(r2, function () {
var len = arguments.length; // Skip index 0 and the last 2
for (var i = 1; i < len - 2; ++i) {
if ((i < 0 || arguments.length <= i ? undefined : arguments[i]) === undefined) {
match[i] = undefined;
}
}
});
} // Attach named capture properties
if (this[REGEX_DATA] && this[REGEX_DATA].captureNames) {
var groupsObject = match;
if (XRegExp.isInstalled('namespacing')) {
// https://tc39.github.io/proposal-regexp-named-groups/#sec-regexpbuiltinexec
match.groups = (0, _create["default"])(null);
groupsObject = match.groups;
} // Skip index 0
for (var i = 1; i < match.length; ++i) {
var name = this[REGEX_DATA].captureNames[i - 1];
if (name) {
groupsObject[name] = match[i];
}
} // Preserve any existing `groups` obj that came from native ES2018 named capture
} else if (!match.groups && XRegExp.isInstalled('namespacing')) {
match.groups = undefined;
} // Fix browsers that increment `lastIndex` after zero-length matches
if (this.global && !match[0].length && this.lastIndex > match.index) {
this.lastIndex = match.index;
}
}
if (!this.global) {
// Fixes IE, Opera bug (last tested IE 9, Opera 11.6)
this.lastIndex = origLastIndex;
}
return match;
};
/**
* Fixes browser bugs in the native `RegExp.prototype.test`.
*
* @memberOf RegExp
* @param {String} str String to search.
* @returns {boolean} Whether the regex matched the provided value.
*/
fixed.test = function (str) {
// Do this the easy way :-)
return !!fixed.exec.call(this, str);
};
/**
* Adds named capture support (with backreferences returned as `result.name`), and fixes browser
* bugs in the native `String.prototype.match`.
*
* @memberOf String
* @param {RegExp|*} regex Regex to search with. If not a regex object, it is passed to `RegExp`.
* @returns {Array} If `regex` uses flag g, an array of match strings or `null`. Without flag g,
* the result of calling `regex.exec(this)`.
*/
fixed.match = function (regex) {
if (!XRegExp.isRegExp(regex)) {
// Use the native `RegExp` rather than `XRegExp`
regex = new RegExp(regex);
} else if (regex.global) {
var result = String.prototype.match.apply(this, arguments); // Fixes IE bug
regex.lastIndex = 0;
return result;
}
return fixed.exec.call(regex, nullThrows(this));
};
/**
* Adds support for `${n}` (or `$<n>`) tokens for named and numbered backreferences in replacement
* text, and provides named backreferences to replacement functions as `arguments[0].name`. Also
* fixes browser bugs in replacement text syntax when performing a replacement using a nonregex
* search value, and the value of a replacement regex's `lastIndex` property during replacement
* iterations and upon completion. Note that this doesn't support SpiderMonkey's proprietary third
* (`flags`) argument. Use via `XRegExp.replace`.
*
* @memberOf String
* @param {RegExp|String} search Search pattern to be replaced.
* @param {String|Function} replacement Replacement string or a function invoked to create it.
* @returns {string} New string with one or all matches replaced.
*/
fixed.replace = function (search, replacement) {
var isRegex = XRegExp.isRegExp(search);
var origLastIndex;
var captureNames;
var result;
if (isRegex) {
if (search[REGEX_DATA]) {
captureNames = search[REGEX_DATA].captureNames;
} // Only needed if `search` is nonglobal
origLastIndex = search.lastIndex;
} else {
search += ''; // Type-convert
} // Don't use `typeof`; some older browsers return 'function' for regex objects
if (isType(replacement, 'Function')) {
// Stringifying `this` fixes a bug in IE < 9 where the last argument in replacement
// functions isn't type-converted to a string
result = String(this).replace(search, function () {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
if (captureNames) {
var groupsObject;
if (XRegExp.isInstalled('namespacing')) {
// https://tc39.github.io/proposal-regexp-named-groups/#sec-regexpbuiltinexec
groupsObject = (0, _create["default"])(null);
args.push(groupsObject);
} else {
// Change the `args[0]` string primitive to a `String` object that can store
// properties. This really does need to use `String` as a constructor
args[0] = new String(args[0]);
groupsObject = args[0];
} // Store named backreferences
for (var i = 0; i < captureNames.length; ++i) {
if (captureNames[i]) {
groupsObject[captureNames[i]] = args[i + 1];
}
}
} // ES6 specs the context for replacement functions as `undefined`
return replacement.apply(void 0, args);
});
} else {
// Ensure that the last value of `args` will be a string when given nonstring `this`,
// while still throwing on null or undefined context
result = String(nullThrows(this)).replace(search, function () {
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
return String(replacement).replace(replacementToken, replacer);
function replacer($0, bracketed, angled, dollarToken) {
bracketed = bracketed || angled; // ES2018 added a new trailing `groups` arg that's passed to replacement functions
// when the search regex uses native named capture
var numNonCaptureArgs = isType(args[args.length - 1], 'Object') ? 4 : 3;
var numCaptures = args.length - numNonCaptureArgs; // Handle named or numbered backreference with curly or angled braces: ${n}, $<n>
if (bracketed) {
// Handle backreference to numbered capture, if `bracketed` is an integer. Use
// `0` for the entire match. Any number of leading zeros may be used.
if (/^\d+$/.test(bracketed)) {
// Type-convert and drop leading zeros
var _n = +bracketed;
if (_n <= numCaptures) {
return args[_n] || '';
}
} // Handle backreference to named capture. If the name does not refer to an
// existing capturing group, it's an error. Also handles the error for numbered
// backference that does not refer to an existing group.
// Using `indexOf` since having groups with the same name is already an error,
// otherwise would need `lastIndexOf`.
var n = captureNames ? (0, _indexOf["default"])(captureNames).call(captureNames, bracketed) : -1;
if (n < 0) {
throw new SyntaxError("Backreference to undefined group ".concat($0));
}
return args[n + 1] || '';
} // Handle `$`-prefixed variable
// Handle space/blank first because type conversion with `+` drops space padding
// and converts spaces and empty strings to `0`
if (dollarToken === '' || dollarToken === ' ') {
throw new SyntaxError("Invalid token ".concat($0));
}
if (dollarToken === '&' || +dollarToken === 0) {
// $&, $0 (not followed by 1-9), $00
return args[0];
}
if (dollarToken === '$') {
// $$
return '$';
}
if (dollarToken === '`') {
var _context4;
// $` (left context)
return (0, _slice["default"])(_context4 = args[args.length - 1]).call(_context4, 0, args[args.length - 2]);
}
if (dollarToken === "'") {
var _context5;
// $' (right context)
return (0, _slice["default"])(_context5 = args[args.length - 1]).call(_context5, args[args.length - 2] + args[0].length);
} // Handle numbered backreference without braces
// Type-convert and drop leading zero
dollarToken = +dollarToken; // XRegExp behavior for `$n` and `$nn`:
// - Backrefs end after 1 or 2 digits. Use `${..}` or `$<..>` for more digits.
// - `$1` is an error if no capturing groups.
// - `$10` is an error if less than 10 capturing groups. Use `${1}0` or `$<1>0`
// instead.
// - `$01` is `$1` if at least one capturing group, else it's an error.
// - `$0` (not followed by 1-9) and `$00` are the entire match.
// Native behavior, for comparison:
// - Backrefs end after 1 or 2 digits. Cannot reference capturing group 100+.
// - `$1` is a literal `$1` if no capturing groups.
// - `$10` is `$1` followed by a literal `0` if less than 10 capturing groups.
// - `$01` is `$1` if at least one capturing group, else it's a literal `$01`.
// - `$0` is a literal `$0`.
if (!isNaN(dollarToken)) {
if (dollarToken > numCaptures) {
throw new SyntaxError("Backreference to undefined group ".concat($0));
}
return args[dollarToken] || '';
} // `$` followed by an unsupported char is an error, unlike native JS
throw new SyntaxError("Invalid token ".concat($0));
}
});
}
if (isRegex) {
if (search.global) {
// Fixes IE, Safari bug (last tested IE 9, Safari 5.1)
search.lastIndex = 0;
} else {
// Fixes IE, Opera bug (last tested IE 9, Opera 11.6)
search.lastIndex = origLastIndex;
}
}
return result;
};
/**
* Fixes browser bugs in the native `String.prototype.split`. Use via `XRegExp.split`.
*
* @memberOf String
* @param {RegExp|String} separator Regex or string to use for separating the string.
* @param {Number} [limit] Maximum number of items to include in the result array.
* @returns {!Array} Array of substrings.
*/
fixed.split = function (separator, limit) {
if (!XRegExp.isRegExp(separator)) {
// Browsers handle nonregex split correctly, so use the faster native method
return String.prototype.split.apply(this, arguments);
}
var str = String(this);
var output = [];
var origLastIndex = separator.lastIndex;
var lastLastIndex = 0;
var lastLength; // Values for `limit`, per the spec:
// If undefined: pow(2,32) - 1
// If 0, Infinity, or NaN: 0
// If positive number: limit = floor(limit); if (limit >= pow(2,32)) limit -= pow(2,32);
// If negative number: pow(2,32) - floor(abs(limit))
// If other: Type-convert, then use the above rules
// This line fails in very strange ways for some values of `limit` in Opera 10.5-10.63, unless
// Opera Dragonfly is open (go figure). It works in at least Opera 9.5-10.1 and 11+
limit = (limit === undefined ? -1 : limit) >>> 0;
(0, _forEach["default"])(XRegExp).call(XRegExp, str, separator, function (match) {
// This condition is not the same as `if (match[0].length)`
if (match.index + match[0].length > lastLastIndex) {
output.push((0, _slice["default"])(str).call(str, lastLastIndex, match.index));
if (match.length > 1 && match.index < str.length) {
Array.prototype.push.apply(output, (0, _slice["default"])(match).call(match, 1));
}
lastLength = match[0].length;
lastLastIndex = match.index + lastLength;
}
});
if (lastLastIndex === str.length) {
if (!separator.test('') || lastLength) {
output.push('');
}
} else {
output.push((0, _slice["default"])(str).call(str, lastLastIndex));
}
separator.lastIndex = origLastIndex;
return output.length > limit ? (0, _slice["default"])(output).call(output, 0, limit) : output;
}; // ==--------------------------==
// Built-in syntax/flag tokens
// ==--------------------------==
/*
* Letter escapes that natively match literal characters: `\a`, `\A`, etc. These should be
* SyntaxErrors but are allowed in web reality. XRegExp makes them errors for cross-browser
* consistency and to reserve their syntax, but lets them be superseded by addons.
*/
XRegExp.addToken(/\\([ABCE-RTUVXYZaeg-mopqyz]|c(?![A-Za-z])|u(?![\dA-Fa-f]{4}|{[\dA-Fa-f]+})|x(?![\dA-Fa-f]{2}))/, function (match, scope) {
// \B is allowed in default scope only
if (match[1] === 'B' && scope === defaultScope) {
return match[0];
}
throw new SyntaxError("Invalid escape ".concat(match[0]));
}, {
scope: 'all',
leadChar: '\\'
});
/*
* Unicode code point escape with curly braces: `\u{N..}`. `N..` is any one or more digit
* hexadecimal number from 0-10FFFF, and can include leading zeros. Requires the native ES6 `u` flag
* to support code points greater than U+FFFF. Avoids converting code points above U+FFFF to
* surrogate pairs (which could be done without flag `u`), since that could lead to broken behavior
* if you follow a `\u{N..}` token that references a code point above U+FFFF with a quantifier, or
* if you use the same in a character class.
*/
XRegExp.addToken(/\\u{([\dA-Fa-f]+)}/, function (match, scope, flags) {
var code = dec(match[1]);
if (code > 0x10FFFF) {
throw new SyntaxError("Invalid Unicode code point ".concat(match[0]));
}
if (code <= 0xFFFF) {
// Converting to \uNNNN avoids needing to escape the literal character and keep it
// separate from preceding tokens
return "\\u".concat(pad4(hex(code)));
} // If `code` is between 0xFFFF and 0x10FFFF, require and defer to native handling
if (hasNativeU && (0, _indexOf["default"])(flags).call(flags, 'u') !== -1) {
return match[0];
}
throw new SyntaxError('Cannot use Unicode code point above \\u{FFFF} without flag u');
}, {
scope: 'all',
leadChar: '\\'
});
/*
* Comment pattern: `(?# )`. Inline comments are an alternative to the line comments allowed in
* free-spacing mode (flag x).
*/
XRegExp.addToken(/\(\?#[^)]*\)/, getContextualTokenSeparator, {
leadChar: '('
});
/*
* Whitespace and line comments, in free-spacing mode (aka extended mode, flag x) only.
*/
XRegExp.addToken(/\s+|#[^\n]*\n?/, getContextualTokenSeparator, {
flag: 'x'
});
/*
* Dot, in dotAll mode (aka singleline mode, flag s) only.
*/
if (!hasNativeS) {
XRegExp.addToken(/\./, function () {
return '[\\s\\S]';
}, {
flag: 's',
leadChar: '.'
});
}
/*
* Named backreference: `\k<name>`. Backreference names can use RegExpIdentifierName characters
* only. Also allows numbered backreferences as `\k<n>`.
*/
XRegExp.addToken(/\\k<([^>]+)>/, function (match) {
var _context6, _context7;
// Groups with the same name is an error, else would need `lastIndexOf`
var index = isNaN(match[1]) ? (0, _indexOf["default"])(_context6 = this.captureNames).call(_context6, match[1]) + 1 : +match[1];
var endIndex = match.index + match[0].length;
if (!index || index > this.captureNames.length) {
throw new SyntaxError("Backreference to undefined group ".concat(match[0]));
} // Keep backreferences separate from subsequent literal numbers. This avoids e.g.
// inadvertedly changing `(?<n>)\k<n>1` to `()\11`.
return (0, _concat["default"])(_context7 = "\\".concat(index)).call(_context7, endIndex === match.input.length || isNaN(match.input[endIndex]) ? '' : '(?:)');
}, {
leadChar: '\\'
});
/*
* Numbered backreference or octal, plus any following digits: `\0`, `\11`, etc. Octals except `\0`
* not followed by 0-9 and backreferences to unopened capture groups throw an error. Other matches
* are returned unaltered. IE < 9 doesn't support backreferences above `\99` in regex syntax.
*/
XRegExp.addToken(/\\(\d+)/, function (match, scope) {
if (!(scope === defaultScope && /^[1-9]/.test(match[1]) && +match[1] <= this.captureNames.length) && match[1] !== '0') {
throw new SyntaxError("Cannot use octal escape or backreference to undefined group ".concat(match[0]));
}
return match[0];
}, {
scope: 'all',
leadChar: '\\'
});
/*
* Named capturing group; match the opening delimiter only: `(?<name>`. Capture names can use the
* RegExpIdentifierName characters only. Names can't be integers. Supports Python-style
* `(?P<name>` as an alternate syntax to avoid issues in some older versions of Opera which natively
* supported the Python-style syntax. Otherwise, XRegExp might treat numbered backreferences to
* Python-style named capture as octals.
*/
XRegExp.addToken(/\(\?P?<((?:[\$A-Z_a-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u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105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uF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\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\u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\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF38\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])(?:[\$0-9A-Z_a-z\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05EF-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u07FD\u0800-\u082D\u0840-\u085B\u0860-\u086A\u0870-\u0887\u0889-\u088E\u0898-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u09FE\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0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u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1715\u171F-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u180F-\u1819\u1820-\u1878\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1ABF-\u1ACE\u1B00-\u1B4C\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CD0-\u1CD2\u1CD4-\u1CFA\u1D00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA827\uA82C\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uA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A]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD27\uDD30-\uDD39\uDE80-\uDEA9\uDEAB\uDEAC\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF50\uDF70-\uDF85\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC00-\uDC46\uDC66-\uDC75\uDC7F-\uDCBA\uDCC2\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD44-\uDD47\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDC9-\uDDCC\uDDCE-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3B-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC5E-\uDC61\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB8\uDEC0-\uDEC9\uDF00-\uDF1A\uDF1D-\uDF2B\uDF30-\uDF39\uDF40-\uDF46]|\uD806[\uDC00-\uDC3A\uDCA0-\uDCE9\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD35\uDD37\uDD38\uDD3B-\uDD43\uDD50-\uDD59\uDDA0-\uDDA7\uDDAA-\uDDD7\uDDDA-\uDDE1\uDDE3\uDDE4\uDE00-\uDE3E\uDE47\uDE50-\uDE99\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD8E\uDD90\uDD91\uDD93-\uDD98\uDDA0-\uDDA9\uDEE0-\uDEF6\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDE70-\uDEBE\uDEC0-\uDEC9\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF4F-\uDF87\uDF8F-\uDF9F\uDFE0\uDFE1\uDFE3\uDFE4\uDFF0\uDFF1]|\uD821[\uDC00-\uDFF7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uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD83E[\uDFF0-\uDFF9]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF38\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A]|\uDB40[\uDD00-\uDDEF])*)>/, function (match) {
var _context8;
if (!XRegExp.isInstalled('namespacing') && (match[1] === 'length' || match[1] === '__proto__')) {
throw new SyntaxError("Cannot use reserved word as capture name ".concat(match[0]));
}
if ((0, _indexOf["default"])(_context8 = this.captureNames).call(_context8, match[1]) !== -1) {
throw new SyntaxError("Cannot use same name for multiple groups ".concat(match[0]));
}
this.captureNames.push(match[1]);
this.hasNamedCapture = true;
return '(';
}, {
leadChar: '('
});
/*
* Capturing group; match the opening parenthesis only. Required for support of named capturing
* groups. Also adds named capture only mode (flag n).
*/
XRegExp.addToken(/\((?!\?)/, function (match, scope, flags) {
if ((0, _indexOf["default"])(flags).call(flags, 'n') !== -1) {
return '(?:';
}
this.captureNames.push(null);
return '(';
}, {
optionalFlags: 'n',
leadChar: '('
});
var _default = XRegExp;
exports["default"] = _default;
module.exports = exports.default;