re2js 2.8.0 → 2.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.cjs +6526 -0
- package/build/index.d.cts +932 -0
- package/build/index.d.ts +932 -0
- package/build/index.js +6514 -0
- package/build/index.umd.js +6529 -8899
- package/package.json +21 -17
- package/build/index.cjs.cjs +0 -8894
- package/build/index.cjs.cjs.map +0 -1
- package/build/index.esm.d.ts +0 -632
- package/build/index.esm.d.ts.map +0 -1
- package/build/index.esm.js +0 -8883
- package/build/index.esm.js.map +0 -1
- package/build/index.umd.js.map +0 -1
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,932 @@
|
|
|
1
|
+
// Generated by dts-bundle-generator v9.5.1
|
|
2
|
+
|
|
3
|
+
declare class DFA {
|
|
4
|
+
static MAX_CACHE_CLEARS: number;
|
|
5
|
+
constructor(prog: any);
|
|
6
|
+
prog: any;
|
|
7
|
+
stateCache: Map<any, any>;
|
|
8
|
+
stateCount: number;
|
|
9
|
+
startState: any;
|
|
10
|
+
stateLimit: number;
|
|
11
|
+
cacheClears: number;
|
|
12
|
+
failed: boolean;
|
|
13
|
+
clock: number;
|
|
14
|
+
computeClosure(pcs: any): {
|
|
15
|
+
pcs: Int32Array<ArrayBuffer>;
|
|
16
|
+
isMatch: boolean;
|
|
17
|
+
matchIDs: any[];
|
|
18
|
+
};
|
|
19
|
+
getState(pcs: any): any;
|
|
20
|
+
evictCache(): void;
|
|
21
|
+
step(state: any, charCode: any, anchor: any): any;
|
|
22
|
+
match(input: any, pos: any, anchor: any): boolean;
|
|
23
|
+
matchSet(input: any, pos: any, anchor: any): any[];
|
|
24
|
+
}
|
|
25
|
+
declare class Prog {
|
|
26
|
+
inst: any[];
|
|
27
|
+
start: number;
|
|
28
|
+
numCap: number;
|
|
29
|
+
lbStarts: any[];
|
|
30
|
+
numLb: number;
|
|
31
|
+
getInst(pc: any): any;
|
|
32
|
+
numInst(): number;
|
|
33
|
+
addInst(op: any): void;
|
|
34
|
+
skipNop(pc: any): any;
|
|
35
|
+
prefix(): (string | boolean)[];
|
|
36
|
+
startCond(): number;
|
|
37
|
+
patch(l: any, val: any): void;
|
|
38
|
+
append(l1: any, l2: any): any;
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* @returns {string}
|
|
42
|
+
*/
|
|
43
|
+
toString(): string;
|
|
44
|
+
}
|
|
45
|
+
export class RE2Set {
|
|
46
|
+
/** @type {number} */
|
|
47
|
+
static UNANCHORED: number;
|
|
48
|
+
/** @type {number} */
|
|
49
|
+
static ANCHOR_START: number;
|
|
50
|
+
/** @type {number} */
|
|
51
|
+
static ANCHOR_BOTH: number;
|
|
52
|
+
/**
|
|
53
|
+
* Constructs a new RE2Set with the specified anchor mode and flags.
|
|
54
|
+
* @param {number} [anchor=RE2Set.UNANCHORED] - The anchoring mode (e.g., RE2Set.UNANCHORED).
|
|
55
|
+
* @param {number} [flags=0] - The public flags to apply to all patterns in the set.
|
|
56
|
+
*/
|
|
57
|
+
constructor(anchor?: number, flags?: number);
|
|
58
|
+
anchor: number;
|
|
59
|
+
jsFlags: number;
|
|
60
|
+
re2Flags: number;
|
|
61
|
+
regexps: any[];
|
|
62
|
+
prog: Prog;
|
|
63
|
+
dfa: DFA;
|
|
64
|
+
dummyRe2: {
|
|
65
|
+
prog: Prog;
|
|
66
|
+
cond: number;
|
|
67
|
+
prefix: string;
|
|
68
|
+
prefixRune: number;
|
|
69
|
+
longest: boolean;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Adds a new regular expression pattern to the set.
|
|
73
|
+
* Patterns cannot be added after the set has been compiled.
|
|
74
|
+
* @param {string} pattern - The regular expression pattern to add.
|
|
75
|
+
* @returns {number} The integer index assigned to the added pattern.
|
|
76
|
+
* @throws {RE2JSCompileException} If patterns are added after compilation.
|
|
77
|
+
*/
|
|
78
|
+
add(pattern: string): number;
|
|
79
|
+
/**
|
|
80
|
+
* Compiles the added patterns into a single state machine.
|
|
81
|
+
* This is automatically called on the first match if not called explicitly.
|
|
82
|
+
* @returns {void}
|
|
83
|
+
*/
|
|
84
|
+
compile(): void;
|
|
85
|
+
/**
|
|
86
|
+
* Matches the input against the compiled set of regular expressions.
|
|
87
|
+
* @param {string|number[]|Uint8Array} input - The input string or UTF-8 byte array to match against.
|
|
88
|
+
* @returns {number[]} An array of indices representing the patterns that successfully matched the input.
|
|
89
|
+
*/
|
|
90
|
+
match(input: string | number[] | Uint8Array): number[];
|
|
91
|
+
}
|
|
92
|
+
export class MatcherInput {
|
|
93
|
+
/**
|
|
94
|
+
* Return the MatcherInput for UTF_16 encoding.
|
|
95
|
+
* @returns {Utf16MatcherInput}
|
|
96
|
+
*/
|
|
97
|
+
static utf16(charSequence: any): Utf16MatcherInput;
|
|
98
|
+
/**
|
|
99
|
+
* Return the MatcherInput for UTF_8 encoding.
|
|
100
|
+
* @returns {Utf8MatcherInput}
|
|
101
|
+
*/
|
|
102
|
+
static utf8(input: any): Utf8MatcherInput;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Abstract the representations of input text supplied to Matcher.
|
|
106
|
+
*/
|
|
107
|
+
export class MatcherInputBase {
|
|
108
|
+
static Encoding: any;
|
|
109
|
+
getEncoding(): void;
|
|
110
|
+
/** @returns {string} */
|
|
111
|
+
asCharSequence(): string;
|
|
112
|
+
/** @returns {Uint8Array|number[]} */
|
|
113
|
+
asBytes(): Uint8Array | number[];
|
|
114
|
+
/** @returns {number} */
|
|
115
|
+
length(): number;
|
|
116
|
+
/**
|
|
117
|
+
*
|
|
118
|
+
* @returns {boolean}
|
|
119
|
+
*/
|
|
120
|
+
isUTF8Encoding(): boolean;
|
|
121
|
+
/**
|
|
122
|
+
*
|
|
123
|
+
* @returns {boolean}
|
|
124
|
+
*/
|
|
125
|
+
isUTF16Encoding(): boolean;
|
|
126
|
+
}
|
|
127
|
+
declare class Utf16MatcherInput extends MatcherInputBase {
|
|
128
|
+
/** @param {string|null} charSequence */
|
|
129
|
+
constructor(charSequence?: string | null);
|
|
130
|
+
charSequence: string;
|
|
131
|
+
getEncoding(): any;
|
|
132
|
+
/**
|
|
133
|
+
*
|
|
134
|
+
* @returns {number[]}
|
|
135
|
+
*/
|
|
136
|
+
asBytes(): number[];
|
|
137
|
+
}
|
|
138
|
+
declare class Utf8MatcherInput extends MatcherInputBase {
|
|
139
|
+
/** @param {Uint8Array|number[]|null} bytes */
|
|
140
|
+
constructor(bytes?: Uint8Array | number[] | null);
|
|
141
|
+
bytes: number[] | Uint8Array<ArrayBufferLike>;
|
|
142
|
+
getEncoding(): any;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* A stateful iterator that interprets a regex {@code RE2JS} on a specific input.
|
|
146
|
+
*
|
|
147
|
+
* Conceptually, a Matcher consists of four parts:
|
|
148
|
+
* <ol>
|
|
149
|
+
* <li>A compiled regular expression {@code RE2JS}, set at construction and fixed for the lifetime
|
|
150
|
+
* of the matcher.</li>
|
|
151
|
+
*
|
|
152
|
+
* <li>The remainder of the input string, set at construction or {@link #reset()} and advanced by
|
|
153
|
+
* each match operation such as {@link #find}, {@link #matches} or {@link #lookingAt}.</li>
|
|
154
|
+
*
|
|
155
|
+
* <li>The current match information, accessible via {@link #start}, {@link #end}, and
|
|
156
|
+
* {@link #group}, and updated by each match operation.</li>
|
|
157
|
+
*
|
|
158
|
+
* <li>The append position, used and advanced by {@link #appendReplacement} and {@link #appendTail}
|
|
159
|
+
* if performing a search and replace from the input to an external {@code StringBuffer}.
|
|
160
|
+
*
|
|
161
|
+
* </ol>
|
|
162
|
+
*
|
|
163
|
+
*
|
|
164
|
+
* @author rsc@google.com (Russ Cox)
|
|
165
|
+
*/
|
|
166
|
+
export class Matcher {
|
|
167
|
+
/**
|
|
168
|
+
* V8 and WebKit have historical hard limits on the number of arguments
|
|
169
|
+
* that can be passed to a function. We cap replacer arguments to prevent
|
|
170
|
+
* Call Stack Overflow (DoS) vulnerabilities on massive ASTs.
|
|
171
|
+
*/
|
|
172
|
+
static MAX_REPLACER_ARGS: number;
|
|
173
|
+
/**
|
|
174
|
+
* Quotes '\' and '$' in {@code s}, so that the returned string could be used in
|
|
175
|
+
* {@link #appendReplacement} as a literal replacement of {@code s}.
|
|
176
|
+
*
|
|
177
|
+
* @param {string} str the string to be quoted
|
|
178
|
+
* @param {boolean} [javaMode=false] whether the replacement will be used in javaMode
|
|
179
|
+
* @returns {string} the quoted string
|
|
180
|
+
*/
|
|
181
|
+
static quoteReplacement(str: string, javaMode?: boolean): string;
|
|
182
|
+
/**
|
|
183
|
+
*
|
|
184
|
+
* @param {import('./index.js').RE2JS} pattern
|
|
185
|
+
* @param {string|number[]|Uint8Array|MatcherInputBase} input
|
|
186
|
+
*/
|
|
187
|
+
constructor(pattern: RE2JS, input: string | number[] | Uint8Array | MatcherInputBase);
|
|
188
|
+
/**
|
|
189
|
+
* The pattern being matched.
|
|
190
|
+
* @type {import('./index.js').RE2JS}
|
|
191
|
+
*/
|
|
192
|
+
patternInput: RE2JS;
|
|
193
|
+
/** @type {number} */
|
|
194
|
+
patternGroupCount: number;
|
|
195
|
+
/** @type {number[]} */
|
|
196
|
+
groups: number[];
|
|
197
|
+
/** @type {Record<string, number>} */
|
|
198
|
+
namedGroups: Record<string, number>;
|
|
199
|
+
/** @type {number} */
|
|
200
|
+
numberOfInstructions: number;
|
|
201
|
+
/**
|
|
202
|
+
* Returns the {@code RE2JS} associated with this {@code Matcher}.
|
|
203
|
+
* @returns {import('./index.js').RE2JS}
|
|
204
|
+
*/
|
|
205
|
+
pattern(): RE2JS;
|
|
206
|
+
/**
|
|
207
|
+
* Resets the {@code Matcher}, rewinding input and discarding any match information.
|
|
208
|
+
*
|
|
209
|
+
* @returns {Matcher} the {@code Matcher} itself, for chained method calls
|
|
210
|
+
*/
|
|
211
|
+
reset(): Matcher;
|
|
212
|
+
/** @type {number} */
|
|
213
|
+
matcherInputLength: number;
|
|
214
|
+
/** @type {number} */
|
|
215
|
+
appendPos: number;
|
|
216
|
+
hasMatch: boolean;
|
|
217
|
+
hasGroups: boolean;
|
|
218
|
+
anchorFlag: number;
|
|
219
|
+
/**
|
|
220
|
+
* Resets the {@code Matcher} and changes the input.
|
|
221
|
+
* @param {MatcherInputBase} input
|
|
222
|
+
* @returns {Matcher} the {@code Matcher} itself, for chained method calls
|
|
223
|
+
*/
|
|
224
|
+
resetMatcherInput(input: MatcherInputBase): Matcher;
|
|
225
|
+
matcherInput: MatcherInputBase;
|
|
226
|
+
/**
|
|
227
|
+
* Returns the start of the named group of the most recent match, or -1 if the group was not
|
|
228
|
+
* matched.
|
|
229
|
+
* @param {string|number} [group=0]
|
|
230
|
+
* @returns {number}
|
|
231
|
+
*/
|
|
232
|
+
start(group?: string | number): number;
|
|
233
|
+
/**
|
|
234
|
+
* Returns the end of the named group of the most recent match, or -1 if the group was not
|
|
235
|
+
* matched.
|
|
236
|
+
* @param {string|number} [group=0]
|
|
237
|
+
* @returns {number}
|
|
238
|
+
*/
|
|
239
|
+
end(group?: string | number): number;
|
|
240
|
+
/**
|
|
241
|
+
* Returns the program size of this pattern.
|
|
242
|
+
*
|
|
243
|
+
* <p>
|
|
244
|
+
* Similar to the C++ implementation, the program size is a very approximate measure of a regexp's
|
|
245
|
+
* "cost". Larger numbers are more expensive than smaller numbers.
|
|
246
|
+
* </p>
|
|
247
|
+
*
|
|
248
|
+
* @returns {number} the program size of this pattern
|
|
249
|
+
*/
|
|
250
|
+
programSize(): number;
|
|
251
|
+
/**
|
|
252
|
+
* Returns the named group of the most recent match, or {@code null} if the group was not matched.
|
|
253
|
+
* @param {string|number} [group=0]
|
|
254
|
+
* @returns {string|null}
|
|
255
|
+
*/
|
|
256
|
+
group(group?: string | number): string | null;
|
|
257
|
+
/**
|
|
258
|
+
* Returns a dictionary map of all named capturing groups and their matched values.
|
|
259
|
+
* If a group was not matched, its value will be `null`.
|
|
260
|
+
* @returns {Record<string, string|null>}
|
|
261
|
+
*/
|
|
262
|
+
getNamedGroups(): Record<string, string | null>;
|
|
263
|
+
/**
|
|
264
|
+
* Returns the number of subgroups in this pattern.
|
|
265
|
+
*
|
|
266
|
+
* @returns {number} the number of subgroups; the overall match (group 0) does not count
|
|
267
|
+
*/
|
|
268
|
+
groupCount(): number;
|
|
269
|
+
/**
|
|
270
|
+
* Helper: finds subgroup information if needed for group.
|
|
271
|
+
* @param {number} group
|
|
272
|
+
* @private
|
|
273
|
+
*/
|
|
274
|
+
private loadGroup;
|
|
275
|
+
/**
|
|
276
|
+
* Matches the entire input against the pattern (anchored start and end). If there is a match,
|
|
277
|
+
* {@code matches} sets the match state to describe it.
|
|
278
|
+
*
|
|
279
|
+
* @returns {boolean} true if the entire input matches the pattern
|
|
280
|
+
*/
|
|
281
|
+
matches(): boolean;
|
|
282
|
+
/**
|
|
283
|
+
* Matches the beginning of input against the pattern (anchored start). If there is a match,
|
|
284
|
+
* {@code lookingAt} sets the match state to describe it.
|
|
285
|
+
*
|
|
286
|
+
* @returns {boolean} true if the beginning of the input matches the pattern
|
|
287
|
+
*/
|
|
288
|
+
lookingAt(): boolean;
|
|
289
|
+
/**
|
|
290
|
+
* Matches the input against the pattern (unanchored), starting at a specified position. If there
|
|
291
|
+
* is a match, {@code find} sets the match state to describe it.
|
|
292
|
+
*
|
|
293
|
+
* @param {number|null} [start=null] the input position where the search begins
|
|
294
|
+
* @returns {boolean} if it finds a match
|
|
295
|
+
* @throws IndexOutOfBoundsException if start is not a valid input position
|
|
296
|
+
*/
|
|
297
|
+
find(start?: number | null): boolean;
|
|
298
|
+
/**
|
|
299
|
+
* Helper: does match starting at start, with RE2 anchor flag.
|
|
300
|
+
* @param {number} startByte
|
|
301
|
+
* @param {number} anchor
|
|
302
|
+
* @returns {boolean}
|
|
303
|
+
* @private
|
|
304
|
+
*/
|
|
305
|
+
private genMatch;
|
|
306
|
+
/**
|
|
307
|
+
* Helper: return substring for [start, end).
|
|
308
|
+
* @param {number} start
|
|
309
|
+
* @param {number} end
|
|
310
|
+
* @returns {string}
|
|
311
|
+
*/
|
|
312
|
+
substring(start: number, end: number): string;
|
|
313
|
+
/**
|
|
314
|
+
* Helper for Pattern: return input length.
|
|
315
|
+
* @returns {number}
|
|
316
|
+
*/
|
|
317
|
+
inputLength(): number;
|
|
318
|
+
/**
|
|
319
|
+
* Appends to result two strings: the text from the append position up to the beginning of the
|
|
320
|
+
* most recent match, and then the replacement with submatch groups substituted for references of
|
|
321
|
+
* the form {@code $n}, where {@code n} is the group number in decimal. It advances the append
|
|
322
|
+
* position to where the most recent match ended.
|
|
323
|
+
*
|
|
324
|
+
* To embed a literal {@code $}, use \$ (actually {@code "\\$"} with string escapes). The escape
|
|
325
|
+
* is only necessary when {@code $} is followed by a digit, but it is always allowed. Only
|
|
326
|
+
* {@code $} and {@code \} need escaping, but any character can be escaped.
|
|
327
|
+
*
|
|
328
|
+
* The group number {@code n} in {@code $n} is always at least one digit and expands to use more
|
|
329
|
+
* digits as long as the resulting number is a valid group number for this pattern. To cut it off
|
|
330
|
+
* earlier, escape the first digit that should not be used.
|
|
331
|
+
*
|
|
332
|
+
* @param {string} replacement the replacement string
|
|
333
|
+
* @param {boolean} [javaMode=false] activate java mode (different behaviour for capture groups and special characters)
|
|
334
|
+
* @returns {string}
|
|
335
|
+
* @throws IllegalStateException if there was no most recent match
|
|
336
|
+
* @throws IndexOutOfBoundsException if replacement refers to an invalid group
|
|
337
|
+
* @private
|
|
338
|
+
*/
|
|
339
|
+
private appendReplacement;
|
|
340
|
+
/**
|
|
341
|
+
* @param {string} replacement - the replacement string
|
|
342
|
+
* @returns {string}
|
|
343
|
+
* @private
|
|
344
|
+
*/
|
|
345
|
+
private appendReplacementInternalJava;
|
|
346
|
+
/**
|
|
347
|
+
* @param {string} replacement - the replacement string
|
|
348
|
+
* @returns {string}
|
|
349
|
+
* @private
|
|
350
|
+
*/
|
|
351
|
+
private appendReplacementInternalJs;
|
|
352
|
+
/**
|
|
353
|
+
* Return the substring of the input from the append position to the end of the
|
|
354
|
+
* input.
|
|
355
|
+
* @returns {string}
|
|
356
|
+
*/
|
|
357
|
+
appendTail(): string;
|
|
358
|
+
/**
|
|
359
|
+
* Returns the input with all matches replaced by {@code replacement}, interpreted as for
|
|
360
|
+
* {@code appendReplacement}.
|
|
361
|
+
*
|
|
362
|
+
* @param {string|((...args: any[]) => string)} replacement - the replacement string or a replacer function
|
|
363
|
+
* @param {boolean} [javaMode=false] - activate java mode (different behaviour for capture groups and special characters)
|
|
364
|
+
* @returns {string} the input string with the matches replaced
|
|
365
|
+
* @throws IndexOutOfBoundsException if replacement refers to an invalid group and javaMode is true
|
|
366
|
+
*/
|
|
367
|
+
replaceAll(replacement: string | ((...args: any[]) => string), javaMode?: boolean): string;
|
|
368
|
+
/**
|
|
369
|
+
* Returns the input with the first match replaced by {@code replacement}, interpreted as for
|
|
370
|
+
* {@code appendReplacement}.
|
|
371
|
+
*
|
|
372
|
+
* @param {string|((...args: any[]) => string)} replacement - the replacement string or a replacer function
|
|
373
|
+
* @param {boolean} [javaMode=false] - activate java mode (different behaviour for capture groups and special characters)
|
|
374
|
+
* @returns {string} the input string with the first match replaced
|
|
375
|
+
* @throws IndexOutOfBoundsException if replacement refers to an invalid group and javaMode is true
|
|
376
|
+
*/
|
|
377
|
+
replaceFirst(replacement: string | ((...args: any[]) => string), javaMode?: boolean): string;
|
|
378
|
+
/**
|
|
379
|
+
* Helper: replaceAll/replaceFirst hybrid.
|
|
380
|
+
* @param {string|((...args: any[]) => string)} replacement - the replacement string or a replacer function
|
|
381
|
+
* @param {boolean} [all=true] - replace all matches
|
|
382
|
+
* @param {boolean} [javaMode=false] - activate java mode (different behaviour for capture groups and special characters)
|
|
383
|
+
* @returns {string}
|
|
384
|
+
* @private
|
|
385
|
+
*/
|
|
386
|
+
private replace;
|
|
387
|
+
/**
|
|
388
|
+
* Evaluates a replacer function for the current match and appends the result,
|
|
389
|
+
* along with any un-matched preceding text, advancing the append position.
|
|
390
|
+
* @param {Function} replacer - the replacer function
|
|
391
|
+
* @param {boolean} hasNamedGroups - cached flag if pattern has named groups
|
|
392
|
+
* @param {string|Uint8Array|number[]} originalInput - the cached original input reference
|
|
393
|
+
* @returns {string} the evaluated string to append
|
|
394
|
+
* @private
|
|
395
|
+
*/
|
|
396
|
+
private appendReplacementFunc;
|
|
397
|
+
/**
|
|
398
|
+
* Builds the argument array for the replacer function matching the standard
|
|
399
|
+
* JS String.prototype.replace(regex, replacer) signature.
|
|
400
|
+
* @param {number} matchStart - the start index of the match
|
|
401
|
+
* @param {boolean} hasNamedGroups - cached flag if pattern has named groups
|
|
402
|
+
* @param {string|Uint8Array|number[]} originalInput - the cached original input reference
|
|
403
|
+
* @returns {Array} array of arguments
|
|
404
|
+
* @private
|
|
405
|
+
*/
|
|
406
|
+
private buildReplacerArgs;
|
|
407
|
+
}
|
|
408
|
+
export class RE2JSException extends Error {
|
|
409
|
+
/** @param {string} message */
|
|
410
|
+
constructor(message: string);
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* An exception thrown by the parser if the pattern was invalid.
|
|
414
|
+
*/
|
|
415
|
+
export class RE2JSSyntaxException extends RE2JSException {
|
|
416
|
+
/**
|
|
417
|
+
* @param {string} error
|
|
418
|
+
* @param {string|null} [input=null]
|
|
419
|
+
*/
|
|
420
|
+
constructor(error: string, input?: string | null);
|
|
421
|
+
/** @type {string} */
|
|
422
|
+
error: string;
|
|
423
|
+
/** @type {string|null} */
|
|
424
|
+
input: string | null;
|
|
425
|
+
/**
|
|
426
|
+
* Retrieves the description of the error.
|
|
427
|
+
* @returns {string}
|
|
428
|
+
*/
|
|
429
|
+
getDescription(): string;
|
|
430
|
+
/**
|
|
431
|
+
* Retrieves the erroneous regular-expression pattern.
|
|
432
|
+
* @returns {string|null}
|
|
433
|
+
*/
|
|
434
|
+
getPattern(): string | null;
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* An exception thrown by the compiler
|
|
438
|
+
*/
|
|
439
|
+
export class RE2JSCompileException extends RE2JSException {
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* An exception thrown by using groups
|
|
443
|
+
*/
|
|
444
|
+
export class RE2JSGroupException extends RE2JSException {
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* An exception thrown by flags
|
|
448
|
+
*/
|
|
449
|
+
export class RE2JSFlagsException extends RE2JSException {
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* An exception thrown for internal engine errors, such as corrupted bytecodes.
|
|
453
|
+
*/
|
|
454
|
+
export class RE2JSInternalException extends RE2JSException {
|
|
455
|
+
}
|
|
456
|
+
declare class RE2 {
|
|
457
|
+
static initTest(expr: any): RE2;
|
|
458
|
+
/**
|
|
459
|
+
* Parses a regular expression and returns, if successful, an {@code RE2} instance that can be
|
|
460
|
+
* used to match against text.
|
|
461
|
+
*
|
|
462
|
+
* When matching against text, the regexp returns a match that begins as early as possible in the
|
|
463
|
+
* input (leftmost), and among those it chooses the one that a backtracking search would have
|
|
464
|
+
* found first. This so-called leftmost-first matching is the same semantics that Perl, Python,
|
|
465
|
+
* and other implementations use, although this package implements it without the expense of
|
|
466
|
+
* backtracking. For POSIX leftmost-longest matching, see {@link #compilePOSIX}.
|
|
467
|
+
*/
|
|
468
|
+
static compile(expr: any): RE2;
|
|
469
|
+
/**
|
|
470
|
+
* {@code compilePOSIX} is like {@link #compile} but restricts the regular expression to POSIX ERE
|
|
471
|
+
* (egrep) syntax and changes the match semantics to leftmost-longest.
|
|
472
|
+
*
|
|
473
|
+
* That is, when matching against text, the regexp returns a match that begins as early as
|
|
474
|
+
* possible in the input (leftmost), and among those it chooses a match that is as long as
|
|
475
|
+
* possible. This so-called leftmost-longest matching is the same semantics that early regular
|
|
476
|
+
* expression implementations used and that POSIX specifies.
|
|
477
|
+
*
|
|
478
|
+
* However, there can be multiple leftmost-longest matches, with different submatch choices, and
|
|
479
|
+
* here this package diverges from POSIX. Among the possible leftmost-longest matches, this
|
|
480
|
+
* package chooses the one that a backtracking search would have found first, while POSIX
|
|
481
|
+
* specifies that the match be chosen to maximize the length of the first subexpression, then the
|
|
482
|
+
* second, and so on from left to right. The POSIX rule is computationally prohibitive and not
|
|
483
|
+
* even well-defined. See http://swtch.com/~rsc/regexp/regexp2.html#posix
|
|
484
|
+
*/
|
|
485
|
+
static compilePOSIX(expr: any): RE2;
|
|
486
|
+
static compileImpl(expr: any, mode: any, longest: any): RE2;
|
|
487
|
+
/**
|
|
488
|
+
* Returns true iff textual regular expression {@code pattern} matches string {@code s}.
|
|
489
|
+
*
|
|
490
|
+
* More complicated queries need to use {@link #compile} and the full {@code RE2} interface.
|
|
491
|
+
*/
|
|
492
|
+
static match(pattern: any, s: any): boolean;
|
|
493
|
+
constructor(expr: any, prog: any, numSubexp?: number, longest?: number);
|
|
494
|
+
expr: any;
|
|
495
|
+
prog: any;
|
|
496
|
+
numSubexp: number;
|
|
497
|
+
longest: number;
|
|
498
|
+
cond: any;
|
|
499
|
+
prefix: any;
|
|
500
|
+
prefixUTF8: any;
|
|
501
|
+
prefixComplete: boolean;
|
|
502
|
+
prefixRune: number;
|
|
503
|
+
pooled: AtomicReference;
|
|
504
|
+
dfa: DFA;
|
|
505
|
+
onepass: {
|
|
506
|
+
start: any;
|
|
507
|
+
numCap: any;
|
|
508
|
+
inst: any[];
|
|
509
|
+
};
|
|
510
|
+
prefilter: any;
|
|
511
|
+
matchPrefixComplete(input: any, pos: any, anchor: any, ncap: any): number[];
|
|
512
|
+
executeEngine(input: any, pos: any, anchor: any, ncap: any): any;
|
|
513
|
+
/**
|
|
514
|
+
* Returns the number of parenthesized subexpressions in this regular expression.
|
|
515
|
+
*/
|
|
516
|
+
numberOfCapturingGroups(): number;
|
|
517
|
+
/**
|
|
518
|
+
* Returns the number of instructions in this compiled regular expression program.
|
|
519
|
+
*/
|
|
520
|
+
numberOfInstructions(): any;
|
|
521
|
+
get(): any;
|
|
522
|
+
reset(): void;
|
|
523
|
+
put(m: any, isNew: any): void;
|
|
524
|
+
toString(): any;
|
|
525
|
+
doExecuteNFA(input: any, pos: any, anchor: any, ncap: any): any;
|
|
526
|
+
match(s: any): boolean;
|
|
527
|
+
/**
|
|
528
|
+
* Matches the regular expression against input starting at position start and ending at position
|
|
529
|
+
* end, with the given anchoring. Records the submatch boundaries in group, which is [start, end)
|
|
530
|
+
* pairs of byte offsets. The number of boundaries needed is inferred from the size of the group
|
|
531
|
+
* array. It is most efficient not to ask for submatch boundaries.
|
|
532
|
+
*
|
|
533
|
+
* @param input the input byte array
|
|
534
|
+
* @param start the beginning position in the input
|
|
535
|
+
* @param end the end position in the input
|
|
536
|
+
* @param anchor the anchoring flag (UNANCHORED, ANCHOR_START, ANCHOR_BOTH)
|
|
537
|
+
* @param group the array to fill with submatch positions
|
|
538
|
+
* @param ngroup the number of array pairs to fill in
|
|
539
|
+
* @returns true if a match was found
|
|
540
|
+
*/
|
|
541
|
+
matchWithGroup(input: any, start: any, end: any, anchor: any, ngroup: any): any[];
|
|
542
|
+
matchMachineInput(input: any, start: any, end: any, anchor: any, ngroup: any): any[];
|
|
543
|
+
/**
|
|
544
|
+
* Returns true iff this regexp matches the UTF-8 byte array {@code b}.
|
|
545
|
+
*/
|
|
546
|
+
matchUTF8(b: any): boolean;
|
|
547
|
+
/**
|
|
548
|
+
* Returns a copy of {@code src} in which all matches for this regexp have been replaced by
|
|
549
|
+
* {@code repl}. No support is provided for expressions (e.g. {@code \1} or {@code $1}) in the
|
|
550
|
+
* replacement string.
|
|
551
|
+
*/
|
|
552
|
+
replaceAll(src: any, repl: any): string;
|
|
553
|
+
/**
|
|
554
|
+
* Returns a copy of {@code src} in which only the first match for this regexp has been replaced
|
|
555
|
+
* by {@code repl}. No support is provided for expressions (e.g. {@code \1} or {@code $1}) in the
|
|
556
|
+
* replacement string.
|
|
557
|
+
*/
|
|
558
|
+
replaceFirst(src: any, repl: any): string;
|
|
559
|
+
/**
|
|
560
|
+
* Returns a copy of {@code src} in which at most {@code maxReplaces} matches for this regexp have
|
|
561
|
+
* been replaced by the return value of of function {@code repl} (whose first argument is the
|
|
562
|
+
* matched string). No support is provided for expressions (e.g. {@code \1} or {@code $1}) in the
|
|
563
|
+
* replacement string.
|
|
564
|
+
*/
|
|
565
|
+
replaceAllFunc(src: any, replFunc: any, maxReplaces: any): string;
|
|
566
|
+
pad(a: any): any;
|
|
567
|
+
allMatches(input: any, n: any, deliverFun?: (v: any) => any): any[];
|
|
568
|
+
/**
|
|
569
|
+
* Returns an array holding the text of the leftmost match in {@code b} of this regular
|
|
570
|
+
* expression.
|
|
571
|
+
*
|
|
572
|
+
* A return value of null indicates no match.
|
|
573
|
+
*/
|
|
574
|
+
findUTF8(b: any): any;
|
|
575
|
+
/**
|
|
576
|
+
* Returns a two-element array of integers defining the location of the leftmost match in
|
|
577
|
+
* {@code b} of this regular expression. The match itself is at {@code b[loc[0]...loc[1]]}.
|
|
578
|
+
*
|
|
579
|
+
* A return value of null indicates no match.
|
|
580
|
+
*/
|
|
581
|
+
findUTF8Index(b: any): any;
|
|
582
|
+
/**
|
|
583
|
+
* Returns a string holding the text of the leftmost match in {@code s} of this regular
|
|
584
|
+
* expression.
|
|
585
|
+
*
|
|
586
|
+
* If there is no match, the return value is an empty string, but it will also be empty if the
|
|
587
|
+
* regular expression successfully matches an empty string. Use {@link #findIndex} or
|
|
588
|
+
* {@link #findSubmatch} if it is necessary to distinguish these cases.
|
|
589
|
+
*/
|
|
590
|
+
find(s: any): any;
|
|
591
|
+
/**
|
|
592
|
+
* Returns a two-element array of integers defining the location of the leftmost match in
|
|
593
|
+
* {@code s} of this regular expression. The match itself is at
|
|
594
|
+
* {@code s.substring(loc[0], loc[1])}.
|
|
595
|
+
*
|
|
596
|
+
* A return value of null indicates no match.
|
|
597
|
+
*/
|
|
598
|
+
findIndex(s: any): any;
|
|
599
|
+
/**
|
|
600
|
+
* Returns an array of arrays the text of the leftmost match of the regular expression in
|
|
601
|
+
* {@code b} and the matches, if any, of its subexpressions, as defined by the <a
|
|
602
|
+
* href='#submatch'>Submatch</a> description above.
|
|
603
|
+
*
|
|
604
|
+
* A return value of null indicates no match.
|
|
605
|
+
*/
|
|
606
|
+
findUTF8Submatch(b: any): any[];
|
|
607
|
+
/**
|
|
608
|
+
* Returns an array holding the index pairs identifying the leftmost match of this regular
|
|
609
|
+
* expression in {@code b} and the matches, if any, of its subexpressions, as defined by the the
|
|
610
|
+
* <a href='#submatch'>Submatch</a> and <a href='#index'>Index</a> descriptions above.
|
|
611
|
+
*
|
|
612
|
+
* A return value of null indicates no match.
|
|
613
|
+
*/
|
|
614
|
+
findUTF8SubmatchIndex(b: any): any;
|
|
615
|
+
/**
|
|
616
|
+
* Returns an array of strings holding the text of the leftmost match of the regular expression in
|
|
617
|
+
* {@code s} and the matches, if any, of its subexpressions, as defined by the <a
|
|
618
|
+
* href='#submatch'>Submatch</a> description above.
|
|
619
|
+
*
|
|
620
|
+
* A return value of null indicates no match.
|
|
621
|
+
*/
|
|
622
|
+
findSubmatch(s: any): any[];
|
|
623
|
+
/**
|
|
624
|
+
* Returns an array holding the index pairs identifying the leftmost match of this regular
|
|
625
|
+
* expression in {@code s} and the matches, if any, of its subexpressions, as defined by the <a
|
|
626
|
+
* href='#submatch'>Submatch</a> description above.
|
|
627
|
+
*
|
|
628
|
+
* A return value of null indicates no match.
|
|
629
|
+
*/
|
|
630
|
+
findSubmatchIndex(s: any): any;
|
|
631
|
+
/**
|
|
632
|
+
* {@code findAllUTF8()} is the <a href='#all'>All</a> version of {@link #findUTF8}; it returns a
|
|
633
|
+
* list of up to {@code n} successive matches of the expression, as defined by the <a
|
|
634
|
+
* href='#all'>All</a> description above.
|
|
635
|
+
*
|
|
636
|
+
* A return value of null indicates no match.
|
|
637
|
+
*
|
|
638
|
+
* TODO(adonovan): think about defining a byte slice view class, like a read-only Go slice backed
|
|
639
|
+
* by |b|.
|
|
640
|
+
*/
|
|
641
|
+
findAllUTF8(b: any, n: any): any[];
|
|
642
|
+
/**
|
|
643
|
+
* {@code findAllUTF8Index} is the <a href='#all'>All</a> version of {@link #findUTF8Index}; it
|
|
644
|
+
* returns a list of up to {@code n} successive matches of the expression, as defined by the <a
|
|
645
|
+
* href='#all'>All</a> description above.
|
|
646
|
+
*
|
|
647
|
+
* A return value of null indicates no match.
|
|
648
|
+
*/
|
|
649
|
+
findAllUTF8Index(b: any, n: any): any[];
|
|
650
|
+
/**
|
|
651
|
+
* {@code findAll} is the <a href='#all'>All</a> version of {@link #find}; it returns a list of up
|
|
652
|
+
* to {@code n} successive matches of the expression, as defined by the <a href='#all'>All</a>
|
|
653
|
+
* description above.
|
|
654
|
+
*
|
|
655
|
+
* A return value of null indicates no match.
|
|
656
|
+
*/
|
|
657
|
+
findAll(s: any, n: any): any[];
|
|
658
|
+
/**
|
|
659
|
+
* {@code findAllIndex} is the <a href='#all'>All</a> version of {@link #findIndex}; it returns a
|
|
660
|
+
* list of up to {@code n} successive matches of the expression, as defined by the <a
|
|
661
|
+
* href='#all'>All</a> description above.
|
|
662
|
+
*
|
|
663
|
+
* A return value of null indicates no match.
|
|
664
|
+
*/
|
|
665
|
+
findAllIndex(s: any, n: any): any[];
|
|
666
|
+
/**
|
|
667
|
+
* {@code findAllUTF8Submatch} is the <a href='#all'>All</a> version of {@link #findUTF8Submatch};
|
|
668
|
+
* it returns a list of up to {@code n} successive matches of the expression, as defined by the <a
|
|
669
|
+
* href='#all'>All</a> description above.
|
|
670
|
+
*
|
|
671
|
+
* A return value of null indicates no match.
|
|
672
|
+
*/
|
|
673
|
+
findAllUTF8Submatch(b: any, n: any): any[];
|
|
674
|
+
/**
|
|
675
|
+
* {@code findAllUTF8SubmatchIndex} is the <a href='#all'>All</a> version of
|
|
676
|
+
* {@link #findUTF8SubmatchIndex}; it returns a list of up to {@code n} successive matches of the
|
|
677
|
+
* expression, as defined by the <a href='#all'>All</a> description above.
|
|
678
|
+
*
|
|
679
|
+
* A return value of null indicates no match.
|
|
680
|
+
*/
|
|
681
|
+
findAllUTF8SubmatchIndex(b: any, n: any): any[];
|
|
682
|
+
/**
|
|
683
|
+
* {@code findAllSubmatch} is the <a href='#all'>All</a> version of {@link #findSubmatch}; it
|
|
684
|
+
* returns a list of up to {@code n} successive matches of the expression, as defined by the <a
|
|
685
|
+
* href='#all'>All</a> description above.
|
|
686
|
+
*
|
|
687
|
+
* A return value of null indicates no match.
|
|
688
|
+
*/
|
|
689
|
+
findAllSubmatch(s: any, n: any): any[];
|
|
690
|
+
/**
|
|
691
|
+
* {@code findAllSubmatchIndex} is the <a href='#all'>All</a> version of
|
|
692
|
+
* {@link #findSubmatchIndex}; it returns a list of up to {@code n} successive matches of the
|
|
693
|
+
* expression, as defined by the <a href='#all'>All</a> description above.
|
|
694
|
+
*
|
|
695
|
+
* A return value of null indicates no match.
|
|
696
|
+
*/
|
|
697
|
+
findAllSubmatchIndex(s: any, n: any): any[];
|
|
698
|
+
}
|
|
699
|
+
declare class AtomicReference {
|
|
700
|
+
constructor(initialValue: any);
|
|
701
|
+
value: any;
|
|
702
|
+
get(): any;
|
|
703
|
+
set(newValue: any): void;
|
|
704
|
+
compareAndSet(expect: any, update: any): boolean;
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* Creates an RE2JS regex directly from a template literal.
|
|
708
|
+
* @overload
|
|
709
|
+
* @param {TemplateStringsArray} stringsOrFlags - The raw string segments of the template literal.
|
|
710
|
+
* @param {...any} values - The interpolated values.
|
|
711
|
+
* @returns {RE2JS}
|
|
712
|
+
*/
|
|
713
|
+
export function re(stringsOrFlags: TemplateStringsArray, ...values: any[]): RE2JS;
|
|
714
|
+
/**
|
|
715
|
+
* Creates a template literal tag function with specific RE2JS flags.
|
|
716
|
+
* @overload
|
|
717
|
+
* @param {number} stringsOrFlags - The RE2JS flags to apply (e.g., RE2JS.CASE_INSENSITIVE).
|
|
718
|
+
* @returns {(strings: TemplateStringsArray, ...tagValues: any[]) => RE2JS}
|
|
719
|
+
*/
|
|
720
|
+
export function re(stringsOrFlags: number): (strings: TemplateStringsArray, ...tagValues: any[]) => RE2JS;
|
|
721
|
+
/**
|
|
722
|
+
* A compiled representation of an RE2 regular expression
|
|
723
|
+
*
|
|
724
|
+
* The matching functions take {@code String} arguments instead of the more general Java
|
|
725
|
+
* {@code CharSequence} since the latter doesn't provide UTF-16 decoding.
|
|
726
|
+
*
|
|
727
|
+
*
|
|
728
|
+
* @author rsc@google.com (Russ Cox)
|
|
729
|
+
* @class
|
|
730
|
+
*/
|
|
731
|
+
export class RE2JS {
|
|
732
|
+
/**
|
|
733
|
+
* Flag: case insensitive matching.
|
|
734
|
+
*/
|
|
735
|
+
static CASE_INSENSITIVE: number;
|
|
736
|
+
/**
|
|
737
|
+
* Flag: dot ({@code .}) matches all characters, including newline.
|
|
738
|
+
*/
|
|
739
|
+
static DOTALL: number;
|
|
740
|
+
/**
|
|
741
|
+
* Flag: multiline matching: {@code ^} and {@code $} match at beginning and end of line, not just
|
|
742
|
+
* beginning and end of input.
|
|
743
|
+
*/
|
|
744
|
+
static MULTILINE: number;
|
|
745
|
+
/**
|
|
746
|
+
* Flag: Unicode groups (e.g. {@code \p\ Greek\} ) will be syntax errors.
|
|
747
|
+
*/
|
|
748
|
+
static DISABLE_UNICODE_GROUPS: number;
|
|
749
|
+
/**
|
|
750
|
+
* Flag: matches longest possible string.
|
|
751
|
+
*/
|
|
752
|
+
static LONGEST_MATCH: number;
|
|
753
|
+
/**
|
|
754
|
+
* Flag: enable linear-time captureless lookbehinds.
|
|
755
|
+
*/
|
|
756
|
+
static LOOKBEHINDS: number;
|
|
757
|
+
/**
|
|
758
|
+
* Returns a literal pattern string for the specified string.
|
|
759
|
+
*
|
|
760
|
+
* This method produces a string that can be used to create a <code>RE2JS</code> that would
|
|
761
|
+
* match the string <code>s</code> as if it were a literal pattern.
|
|
762
|
+
*
|
|
763
|
+
* Metacharacters or escape sequences in the input sequence will be given no special meaning.
|
|
764
|
+
*
|
|
765
|
+
* @param {string} str The string to be literalized
|
|
766
|
+
* @returns {string} A literal string replacement
|
|
767
|
+
*/
|
|
768
|
+
static quote(str: string): string;
|
|
769
|
+
/**
|
|
770
|
+
* Quotes '\' and '$' in {@code str}, so that the returned string could be used in
|
|
771
|
+
* replacement methods as a literal replacement of {@code str}.
|
|
772
|
+
*
|
|
773
|
+
* This is a convenience delegation to {@link Matcher.quoteReplacement}.
|
|
774
|
+
*
|
|
775
|
+
* @param {string} str the string to be quoted
|
|
776
|
+
* @param {boolean} [javaMode=false] whether the replacement will be used in javaMode
|
|
777
|
+
* @returns {string} the quoted string
|
|
778
|
+
*/
|
|
779
|
+
static quoteReplacement(str: string, javaMode?: boolean): string;
|
|
780
|
+
/**
|
|
781
|
+
* Translates a given regular expression string to ensure compatibility with RE2JS.
|
|
782
|
+
*
|
|
783
|
+
* This function preprocesses the input regex string by applying necessary transformations,
|
|
784
|
+
* such as escaping special characters (e.g., `/`), converting named capture groups to
|
|
785
|
+
* RE2JS-compatible syntax, and handling Unicode sequences properly. It ensures that the
|
|
786
|
+
* resulting regex is safe and properly formatted before compilation.
|
|
787
|
+
*
|
|
788
|
+
* @param {string|RegExp} expr - The regular expression string to be translated.
|
|
789
|
+
* @returns {string} - The transformed regular expression string, ready for compilation.
|
|
790
|
+
*/
|
|
791
|
+
static translateRegExp(expr: string | RegExp): string;
|
|
792
|
+
/**
|
|
793
|
+
* Helper: create new RE2JS with given regex and flags. Flregex is the regex with flags applied.
|
|
794
|
+
* @param {string} regex
|
|
795
|
+
* @param {number} [flags=0]
|
|
796
|
+
* @returns {RE2JS}
|
|
797
|
+
*/
|
|
798
|
+
static compile(regex: string, flags?: number): RE2JS;
|
|
799
|
+
/**
|
|
800
|
+
* Matches a string against a regular expression.
|
|
801
|
+
*
|
|
802
|
+
* @param {string} regex the regular expression
|
|
803
|
+
* @param {string|number[]|Uint8Array} input the input
|
|
804
|
+
* @returns {boolean} true if the regular expression matches the entire input
|
|
805
|
+
* @throws RE2JSSyntaxException if the regular expression is malformed
|
|
806
|
+
*/
|
|
807
|
+
static matches(regex: string, input: string | number[] | Uint8Array): boolean;
|
|
808
|
+
/**
|
|
809
|
+
* This is visible for testing.
|
|
810
|
+
* @private
|
|
811
|
+
*/
|
|
812
|
+
private static initTest;
|
|
813
|
+
/**
|
|
814
|
+
*
|
|
815
|
+
* @param {string} pattern
|
|
816
|
+
* @param {number} flags
|
|
817
|
+
*/
|
|
818
|
+
constructor(pattern: string, flags: number);
|
|
819
|
+
patternInput: string;
|
|
820
|
+
flagsInput: number;
|
|
821
|
+
/** @type {import('./RE2.js').RE2} */
|
|
822
|
+
re2Input: RE2;
|
|
823
|
+
/**
|
|
824
|
+
* Releases memory used by internal caches associated with this pattern. Does not change the
|
|
825
|
+
* observable behaviour. Useful for tests that detect memory leaks via allocation tracking.
|
|
826
|
+
*/
|
|
827
|
+
reset(): void;
|
|
828
|
+
/**
|
|
829
|
+
* Returns the flags used in the constructor.
|
|
830
|
+
* @returns {number}
|
|
831
|
+
*/
|
|
832
|
+
flags(): number;
|
|
833
|
+
/**
|
|
834
|
+
* Returns the pattern used in the constructor.
|
|
835
|
+
* @returns {string}
|
|
836
|
+
*/
|
|
837
|
+
pattern(): string;
|
|
838
|
+
re2(): RE2;
|
|
839
|
+
/**
|
|
840
|
+
* Matches a string against a regular expression.
|
|
841
|
+
*
|
|
842
|
+
* @param {string|number[]|Uint8Array} input the input
|
|
843
|
+
* @returns {boolean} true if the regular expression matches the entire input
|
|
844
|
+
*/
|
|
845
|
+
matches(input: string | number[] | Uint8Array): boolean;
|
|
846
|
+
/**
|
|
847
|
+
* Creates a new {@code Matcher} matching the pattern against the input.
|
|
848
|
+
*
|
|
849
|
+
* @param {string|number[]|Uint8Array|MatcherInputBase} input the input string
|
|
850
|
+
* @returns {Matcher}
|
|
851
|
+
*/
|
|
852
|
+
matcher(input: string | number[] | Uint8Array | MatcherInputBase): Matcher;
|
|
853
|
+
/**
|
|
854
|
+
* Tests whether the regular expression matches any part of the input string.
|
|
855
|
+
* Performance Note: This method is highly optimized. Because it only returns
|
|
856
|
+
* a boolean and does not extract capture groups, it bypasses the `Matcher` overhead
|
|
857
|
+
* and guarantees execution on the high-speed DFA engine whenever possible.
|
|
858
|
+
*
|
|
859
|
+
* @param {string|number[]|Uint8Array} input - The input string or UTF-8 byte array to test against.
|
|
860
|
+
* @returns {boolean} `true` if the pattern is found anywhere in the input, `false` otherwise.
|
|
861
|
+
*/
|
|
862
|
+
test(input: string | number[] | Uint8Array): boolean;
|
|
863
|
+
/**
|
|
864
|
+
* Tests whether the regular expression matches the ENTIRE input string.
|
|
865
|
+
* * **Performance Note:** This operates identically to `.matches()`, but is significantly
|
|
866
|
+
* faster because it does not request capture group data. By requesting 0 capture groups,
|
|
867
|
+
* it securely routes execution through the DFA fast-path.
|
|
868
|
+
*
|
|
869
|
+
* @param {string|number[]|Uint8Array} input - The input string or UTF-8 byte array to test against.
|
|
870
|
+
* @returns {boolean} `true` if the exact input string fully matches the pattern, `false` otherwise.
|
|
871
|
+
*/
|
|
872
|
+
testExact(input: string | number[] | Uint8Array): boolean;
|
|
873
|
+
/**
|
|
874
|
+
* Splits input around instances of the regular expression. It returns an array giving the strings
|
|
875
|
+
* that occur before, between, and after instances of the regular expression.
|
|
876
|
+
*
|
|
877
|
+
* If {@code limit <= 0}, there is no limit on the size of the returned array. If
|
|
878
|
+
* {@code limit == 0}, empty strings that would occur at the end of the array are omitted. If
|
|
879
|
+
* {@code limit > 0}, at most limit strings are returned. The final string contains the remainder
|
|
880
|
+
* of the input, possibly including additional matches of the pattern.
|
|
881
|
+
*
|
|
882
|
+
* @param {string} input the input string to be split
|
|
883
|
+
* @param {number} [limit=0] the limit
|
|
884
|
+
* @returns {string[]} the split strings
|
|
885
|
+
*/
|
|
886
|
+
split(input: string, limit?: number): string[];
|
|
887
|
+
/**
|
|
888
|
+
* Returns an iterator of all results matching a string against the regular expression,
|
|
889
|
+
* including capturing groups.
|
|
890
|
+
*
|
|
891
|
+
* @param {string|number[]|Uint8Array} input the input string or byte array
|
|
892
|
+
* @returns {IterableIterator<Array>}
|
|
893
|
+
*/
|
|
894
|
+
matchAll(input: string | number[] | Uint8Array): IterableIterator<any[]>;
|
|
895
|
+
/**
|
|
896
|
+
*
|
|
897
|
+
* @returns {string}
|
|
898
|
+
*/
|
|
899
|
+
toString(): string;
|
|
900
|
+
/**
|
|
901
|
+
* Returns the program size of this pattern.
|
|
902
|
+
*
|
|
903
|
+
* <p>
|
|
904
|
+
* Similar to the C++ implementation, the program size is a very approximate measure of a regexp's
|
|
905
|
+
* "cost". Larger numbers are more expensive than smaller numbers.
|
|
906
|
+
* </p>
|
|
907
|
+
*
|
|
908
|
+
* @returns {number} the program size of this pattern
|
|
909
|
+
*/
|
|
910
|
+
programSize(): number;
|
|
911
|
+
/**
|
|
912
|
+
* Returns the number of capturing groups in this matcher's pattern. Group zero denotes the entire
|
|
913
|
+
* pattern and is excluded from this count.
|
|
914
|
+
*
|
|
915
|
+
* @returns {number} the number of capturing groups in this pattern
|
|
916
|
+
*/
|
|
917
|
+
groupCount(): number;
|
|
918
|
+
/**
|
|
919
|
+
* Return a map of the capturing groups in this matcher's pattern, where key is the name and value
|
|
920
|
+
* is the index of the group in the pattern.
|
|
921
|
+
* @returns {Record<string, number>}
|
|
922
|
+
*/
|
|
923
|
+
namedGroups(): Record<string, number>;
|
|
924
|
+
/**
|
|
925
|
+
*
|
|
926
|
+
* @param {*} other
|
|
927
|
+
* @returns {boolean}
|
|
928
|
+
*/
|
|
929
|
+
equals(other: any): boolean;
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
export {};
|