95 lines
4.3 KiB
JavaScript
95 lines
4.3 KiB
JavaScript
/*
|
|
* (c) Copyright Ascensio System SIA 2010-2024
|
|
*
|
|
* This program is a free software product. You can redistribute it and/or
|
|
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
|
* version 3 as published by the Free Software Foundation. In accordance with
|
|
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
|
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
|
* of any third-party rights.
|
|
*
|
|
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
|
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
|
*
|
|
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
|
* street, Riga, Latvia, EU, LV-1050.
|
|
*
|
|
* The interactive user interfaces in modified source and object code versions
|
|
* of the Program must display Appropriate Legal Notices, as required under
|
|
* Section 5 of the GNU AGPL version 3.
|
|
*
|
|
* Pursuant to Section 7(b) of the License you must retain the original Product
|
|
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
|
* grant you any rights under trademark law for use of our trademarks.
|
|
*
|
|
* All the Product's GUI elements, including illustrations and icon sets, as
|
|
* well as technical writing content are licensed under the terms of the
|
|
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
|
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
|
*
|
|
*/
|
|
|
|
//This file containes definition of object which used in api.js
|
|
//It need to prevent minimize the name of object's method.
|
|
|
|
function XRegExp() {}
|
|
|
|
/**
|
|
* Executes a regex search in a specified string. Returns a match array or `null`. If the provided
|
|
* regex uses named capture, named backreference properties are included on the match array.
|
|
* 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 backreference properties, or `null`.
|
|
* @example
|
|
*
|
|
* // Basic use, with named backreference
|
|
* let match = XRegExp.exec('U+2620', XRegExp('U\\+(?<hex>[0-9A-F]{4})'));
|
|
* match.hex; // -> '2620'
|
|
*
|
|
* // With pos and sticky, in a loop
|
|
* let pos = 2, 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) {};
|
|
|
|
/**
|
|
* Builds regexes using named subpatterns, for readability and pattern reuse. Backreferences in
|
|
* the outer pattern and provided subpatterns are automatically renumbered to work correctly.
|
|
* Native flags used by provided subpatterns are ignored in favor of the `flags` argument.
|
|
*
|
|
* @memberOf XRegExp
|
|
* @param {String} pattern XRegExp pattern using `{{name}}` for embedded subpatterns. Allows
|
|
* `({{name}})` as shorthand for `(?<name>{{name}})`. Patterns cannot be embedded within
|
|
* character classes.
|
|
* @param {Object} subs Lookup object for named subpatterns. Values can be strings or regexes. A
|
|
* leading `^` and trailing unescaped `$` are stripped from subpatterns, if both are present.
|
|
* @param {String} [flags] Any combination of XRegExp flags.
|
|
* @returns {RegExp} Regex with interpolated subpatterns.
|
|
* @example
|
|
*
|
|
* const time = XRegExp.build('(?x)^ {{hours}} ({{minutes}}) $', {
|
|
* hours: XRegExp.build('{{h12}} : | {{h24}}', {
|
|
* h12: /1[0-2]|0?[1-9]/,
|
|
* h24: /2[0-3]|[01][0-9]/
|
|
* }, 'x'),
|
|
* minutes: /^[0-5][0-9]$/
|
|
* });
|
|
* time.test('10:59'); // -> true
|
|
* XRegExp.exec('10:59', time).minutes; // -> '59'
|
|
*/
|
|
XRegExp.build = function (pattern, subs, flags) {};
|