re2js 2.8.0 → 2.8.1
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 +6505 -0
- package/build/index.d.cts +932 -0
- package/build/index.d.ts +932 -0
- package/build/index.js +6493 -0
- package/build/index.umd.js +6508 -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.esm.d.ts
DELETED
|
@@ -1,632 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A stateful iterator that interprets a regex {@code RE2JS} on a specific input.
|
|
3
|
-
*
|
|
4
|
-
* Conceptually, a Matcher consists of four parts:
|
|
5
|
-
* <ol>
|
|
6
|
-
* <li>A compiled regular expression {@code RE2JS}, set at construction and fixed for the lifetime
|
|
7
|
-
* of the matcher.</li>
|
|
8
|
-
*
|
|
9
|
-
* <li>The remainder of the input string, set at construction or {@link #reset()} and advanced by
|
|
10
|
-
* each match operation such as {@link #find}, {@link #matches} or {@link #lookingAt}.</li>
|
|
11
|
-
*
|
|
12
|
-
* <li>The current match information, accessible via {@link #start}, {@link #end}, and
|
|
13
|
-
* {@link #group}, and updated by each match operation.</li>
|
|
14
|
-
*
|
|
15
|
-
* <li>The append position, used and advanced by {@link #appendReplacement} and {@link #appendTail}
|
|
16
|
-
* if performing a search and replace from the input to an external {@code StringBuffer}.
|
|
17
|
-
*
|
|
18
|
-
* </ol>
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* @author rsc@google.com (Russ Cox)
|
|
22
|
-
*/
|
|
23
|
-
export class Matcher {
|
|
24
|
-
/**
|
|
25
|
-
* V8 and WebKit have historical hard limits on the number of arguments
|
|
26
|
-
* that can be passed to a function. We cap replacer arguments to prevent
|
|
27
|
-
* Call Stack Overflow (DoS) vulnerabilities on massive ASTs.
|
|
28
|
-
*/
|
|
29
|
-
static MAX_REPLACER_ARGS: number;
|
|
30
|
-
/**
|
|
31
|
-
* Quotes '\' and '$' in {@code s}, so that the returned string could be used in
|
|
32
|
-
* {@link #appendReplacement} as a literal replacement of {@code s}.
|
|
33
|
-
*
|
|
34
|
-
* @param {string} str the string to be quoted
|
|
35
|
-
* @param {boolean} [javaMode=false] whether the replacement will be used in javaMode
|
|
36
|
-
* @returns {string} the quoted string
|
|
37
|
-
*/
|
|
38
|
-
static quoteReplacement(str: string, javaMode?: boolean): string;
|
|
39
|
-
/**
|
|
40
|
-
*
|
|
41
|
-
* @param {RE2JS} pattern
|
|
42
|
-
* @param {string|number[]|Uint8Array} input
|
|
43
|
-
*/
|
|
44
|
-
constructor(pattern: RE2JS, input: string | number[] | Uint8Array);
|
|
45
|
-
/**
|
|
46
|
-
* The pattern being matched.
|
|
47
|
-
* @type {RE2JS}
|
|
48
|
-
*/
|
|
49
|
-
patternInput: RE2JS;
|
|
50
|
-
/** @type {number} */
|
|
51
|
-
patternGroupCount: number;
|
|
52
|
-
/** @type {number[]} */
|
|
53
|
-
groups: number[];
|
|
54
|
-
/** @type {Record<string, number>} */
|
|
55
|
-
namedGroups: Record<string, number>;
|
|
56
|
-
/** @type {number} */
|
|
57
|
-
numberOfInstructions: number;
|
|
58
|
-
/**
|
|
59
|
-
* Returns the {@code RE2JS} associated with this {@code Matcher}.
|
|
60
|
-
* @returns {RE2JS}
|
|
61
|
-
*/
|
|
62
|
-
pattern(): RE2JS;
|
|
63
|
-
/**
|
|
64
|
-
* Resets the {@code Matcher}, rewinding input and discarding any match information.
|
|
65
|
-
*
|
|
66
|
-
* @returns {Matcher} the {@code Matcher} itself, for chained method calls
|
|
67
|
-
*/
|
|
68
|
-
reset(): Matcher;
|
|
69
|
-
/** @type {number} */
|
|
70
|
-
matcherInputLength: number | undefined;
|
|
71
|
-
/** @type {number} */
|
|
72
|
-
appendPos: number | undefined;
|
|
73
|
-
hasMatch: boolean | undefined;
|
|
74
|
-
hasGroups: boolean | undefined;
|
|
75
|
-
anchorFlag: number | undefined;
|
|
76
|
-
/**
|
|
77
|
-
* Resets the {@code Matcher} and changes the input.
|
|
78
|
-
* @param {MatcherInputBase} input
|
|
79
|
-
* @returns {Matcher} the {@code Matcher} itself, for chained method calls
|
|
80
|
-
*/
|
|
81
|
-
resetMatcherInput(input: MatcherInputBase): Matcher;
|
|
82
|
-
matcherInput: MatcherInputBase | undefined;
|
|
83
|
-
/**
|
|
84
|
-
* Returns the start of the named group of the most recent match, or -1 if the group was not
|
|
85
|
-
* matched.
|
|
86
|
-
* @param {string|number} [group=0]
|
|
87
|
-
* @returns {number}
|
|
88
|
-
*/
|
|
89
|
-
start(group?: string | number): number;
|
|
90
|
-
/**
|
|
91
|
-
* Returns the end of the named group of the most recent match, or -1 if the group was not
|
|
92
|
-
* matched.
|
|
93
|
-
* @param {string|number} [group=0]
|
|
94
|
-
* @returns {number}
|
|
95
|
-
*/
|
|
96
|
-
end(group?: string | number): number;
|
|
97
|
-
/**
|
|
98
|
-
* Returns the program size of this pattern.
|
|
99
|
-
*
|
|
100
|
-
* <p>
|
|
101
|
-
* Similar to the C++ implementation, the program size is a very approximate measure of a regexp's
|
|
102
|
-
* "cost". Larger numbers are more expensive than smaller numbers.
|
|
103
|
-
* </p>
|
|
104
|
-
*
|
|
105
|
-
* @returns {number} the program size of this pattern
|
|
106
|
-
*/
|
|
107
|
-
programSize(): number;
|
|
108
|
-
/**
|
|
109
|
-
* Returns the named group of the most recent match, or {@code null} if the group was not matched.
|
|
110
|
-
* @param {string|number} [group=0]
|
|
111
|
-
* @returns {string|null}
|
|
112
|
-
*/
|
|
113
|
-
group(group?: string | number): string | null;
|
|
114
|
-
/**
|
|
115
|
-
* Returns a dictionary map of all named capturing groups and their matched values.
|
|
116
|
-
* If a group was not matched, its value will be `null`.
|
|
117
|
-
* @returns {Record<string, string|null>}
|
|
118
|
-
*/
|
|
119
|
-
getNamedGroups(): Record<string, string | null>;
|
|
120
|
-
/**
|
|
121
|
-
* Returns the number of subgroups in this pattern.
|
|
122
|
-
*
|
|
123
|
-
* @returns {number} the number of subgroups; the overall match (group 0) does not count
|
|
124
|
-
*/
|
|
125
|
-
groupCount(): number;
|
|
126
|
-
/**
|
|
127
|
-
* Helper: finds subgroup information if needed for group.
|
|
128
|
-
* @param {number} group
|
|
129
|
-
* @private
|
|
130
|
-
*/
|
|
131
|
-
private loadGroup;
|
|
132
|
-
/**
|
|
133
|
-
* Matches the entire input against the pattern (anchored start and end). If there is a match,
|
|
134
|
-
* {@code matches} sets the match state to describe it.
|
|
135
|
-
*
|
|
136
|
-
* @returns {boolean} true if the entire input matches the pattern
|
|
137
|
-
*/
|
|
138
|
-
matches(): boolean;
|
|
139
|
-
/**
|
|
140
|
-
* Matches the beginning of input against the pattern (anchored start). If there is a match,
|
|
141
|
-
* {@code lookingAt} sets the match state to describe it.
|
|
142
|
-
*
|
|
143
|
-
* @returns {boolean} true if the beginning of the input matches the pattern
|
|
144
|
-
*/
|
|
145
|
-
lookingAt(): boolean;
|
|
146
|
-
/**
|
|
147
|
-
* Matches the input against the pattern (unanchored), starting at a specified position. If there
|
|
148
|
-
* is a match, {@code find} sets the match state to describe it.
|
|
149
|
-
*
|
|
150
|
-
* @param {number|null} [start=null] the input position where the search begins
|
|
151
|
-
* @returns {boolean} if it finds a match
|
|
152
|
-
* @throws IndexOutOfBoundsException if start is not a valid input position
|
|
153
|
-
*/
|
|
154
|
-
find(start?: number | null): boolean;
|
|
155
|
-
/**
|
|
156
|
-
* Helper: does match starting at start, with RE2 anchor flag.
|
|
157
|
-
* @param {number} startByte
|
|
158
|
-
* @param {number} anchor
|
|
159
|
-
* @returns {boolean}
|
|
160
|
-
* @private
|
|
161
|
-
*/
|
|
162
|
-
private genMatch;
|
|
163
|
-
/**
|
|
164
|
-
* Helper: return substring for [start, end).
|
|
165
|
-
* @param {number} start
|
|
166
|
-
* @param {number} end
|
|
167
|
-
* @returns {string}
|
|
168
|
-
*/
|
|
169
|
-
substring(start: number, end: number): string;
|
|
170
|
-
/**
|
|
171
|
-
* Helper for Pattern: return input length.
|
|
172
|
-
* @returns {number}
|
|
173
|
-
*/
|
|
174
|
-
inputLength(): number;
|
|
175
|
-
/**
|
|
176
|
-
* Appends to result two strings: the text from the append position up to the beginning of the
|
|
177
|
-
* most recent match, and then the replacement with submatch groups substituted for references of
|
|
178
|
-
* the form {@code $n}, where {@code n} is the group number in decimal. It advances the append
|
|
179
|
-
* position to where the most recent match ended.
|
|
180
|
-
*
|
|
181
|
-
* To embed a literal {@code $}, use \$ (actually {@code "\\$"} with string escapes). The escape
|
|
182
|
-
* is only necessary when {@code $} is followed by a digit, but it is always allowed. Only
|
|
183
|
-
* {@code $} and {@code \} need escaping, but any character can be escaped.
|
|
184
|
-
*
|
|
185
|
-
* The group number {@code n} in {@code $n} is always at least one digit and expands to use more
|
|
186
|
-
* digits as long as the resulting number is a valid group number for this pattern. To cut it off
|
|
187
|
-
* earlier, escape the first digit that should not be used.
|
|
188
|
-
*
|
|
189
|
-
* @param {string} replacement the replacement string
|
|
190
|
-
* @param {boolean} [javaMode=false] activate java mode (different behaviour for capture groups and special characters)
|
|
191
|
-
* @returns {string}
|
|
192
|
-
* @throws IllegalStateException if there was no most recent match
|
|
193
|
-
* @throws IndexOutOfBoundsException if replacement refers to an invalid group
|
|
194
|
-
* @private
|
|
195
|
-
*/
|
|
196
|
-
private appendReplacement;
|
|
197
|
-
/**
|
|
198
|
-
* @param {string} replacement - the replacement string
|
|
199
|
-
* @returns {string}
|
|
200
|
-
* @private
|
|
201
|
-
*/
|
|
202
|
-
private appendReplacementInternalJava;
|
|
203
|
-
/**
|
|
204
|
-
* @param {string} replacement - the replacement string
|
|
205
|
-
* @returns {string}
|
|
206
|
-
* @private
|
|
207
|
-
*/
|
|
208
|
-
private appendReplacementInternalJs;
|
|
209
|
-
/**
|
|
210
|
-
* Return the substring of the input from the append position to the end of the
|
|
211
|
-
* input.
|
|
212
|
-
* @returns {string}
|
|
213
|
-
*/
|
|
214
|
-
appendTail(): string;
|
|
215
|
-
/**
|
|
216
|
-
* Returns the input with all matches replaced by {@code replacement}, interpreted as for
|
|
217
|
-
* {@code appendReplacement}.
|
|
218
|
-
*
|
|
219
|
-
* @param {string|Function} replacement - the replacement string or a replacer function
|
|
220
|
-
* @param {boolean} [javaMode=false] - activate java mode (different behaviour for capture groups and special characters)
|
|
221
|
-
* @returns {string} the input string with the matches replaced
|
|
222
|
-
* @throws IndexOutOfBoundsException if replacement refers to an invalid group and javaMode is true
|
|
223
|
-
*/
|
|
224
|
-
replaceAll(replacement: string | Function, javaMode?: boolean): string;
|
|
225
|
-
/**
|
|
226
|
-
* Returns the input with the first match replaced by {@code replacement}, interpreted as for
|
|
227
|
-
* {@code appendReplacement}.
|
|
228
|
-
*
|
|
229
|
-
* @param {string|Function} replacement - the replacement string or a replacer function
|
|
230
|
-
* @param {boolean} [javaMode=false] - activate java mode (different behaviour for capture groups and special characters)
|
|
231
|
-
* @returns {string} the input string with the first match replaced
|
|
232
|
-
* @throws IndexOutOfBoundsException if replacement refers to an invalid group and javaMode is true
|
|
233
|
-
*/
|
|
234
|
-
replaceFirst(replacement: string | Function, javaMode?: boolean): string;
|
|
235
|
-
/**
|
|
236
|
-
* Helper: replaceAll/replaceFirst hybrid.
|
|
237
|
-
* @param {string|Function} replacement - the replacement string or a replacer function
|
|
238
|
-
* @param {boolean} [all=true] - replace all matches
|
|
239
|
-
* @param {boolean} [javaMode=false] - activate java mode (different behaviour for capture groups and special characters)
|
|
240
|
-
* @returns {string}
|
|
241
|
-
* @private
|
|
242
|
-
*/
|
|
243
|
-
private replace;
|
|
244
|
-
/**
|
|
245
|
-
* Evaluates a replacer function for the current match and appends the result,
|
|
246
|
-
* along with any un-matched preceding text, advancing the append position.
|
|
247
|
-
* @param {Function} replacer - the replacer function
|
|
248
|
-
* @param {boolean} hasNamedGroups - cached flag if pattern has named groups
|
|
249
|
-
* @param {string|Uint8Array|number[]} originalInput - the cached original input reference
|
|
250
|
-
* @returns {string} the evaluated string to append
|
|
251
|
-
* @private
|
|
252
|
-
*/
|
|
253
|
-
private appendReplacementFunc;
|
|
254
|
-
/**
|
|
255
|
-
* Builds the argument array for the replacer function matching the standard
|
|
256
|
-
* JS String.prototype.replace(regex, replacer) signature.
|
|
257
|
-
* @param {number} matchStart - the start index of the match
|
|
258
|
-
* @param {boolean} hasNamedGroups - cached flag if pattern has named groups
|
|
259
|
-
* @param {string|Uint8Array|number[]} originalInput - the cached original input reference
|
|
260
|
-
* @returns {Array} array of arguments
|
|
261
|
-
* @private
|
|
262
|
-
*/
|
|
263
|
-
private buildReplacerArgs;
|
|
264
|
-
}
|
|
265
|
-
/**
|
|
266
|
-
* A compiled representation of an RE2 regular expression
|
|
267
|
-
*
|
|
268
|
-
* The matching functions take {@code String} arguments instead of the more general Java
|
|
269
|
-
* {@code CharSequence} since the latter doesn't provide UTF-16 decoding.
|
|
270
|
-
*
|
|
271
|
-
*
|
|
272
|
-
* @author rsc@google.com (Russ Cox)
|
|
273
|
-
* @class
|
|
274
|
-
*/
|
|
275
|
-
export class RE2JS {
|
|
276
|
-
/**
|
|
277
|
-
* Flag: case insensitive matching.
|
|
278
|
-
*/
|
|
279
|
-
static CASE_INSENSITIVE: number;
|
|
280
|
-
/**
|
|
281
|
-
* Flag: dot ({@code .}) matches all characters, including newline.
|
|
282
|
-
*/
|
|
283
|
-
static DOTALL: number;
|
|
284
|
-
/**
|
|
285
|
-
* Flag: multiline matching: {@code ^} and {@code $} match at beginning and end of line, not just
|
|
286
|
-
* beginning and end of input.
|
|
287
|
-
*/
|
|
288
|
-
static MULTILINE: number;
|
|
289
|
-
/**
|
|
290
|
-
* Flag: Unicode groups (e.g. {@code \p\ Greek\} ) will be syntax errors.
|
|
291
|
-
*/
|
|
292
|
-
static DISABLE_UNICODE_GROUPS: number;
|
|
293
|
-
/**
|
|
294
|
-
* Flag: matches longest possible string.
|
|
295
|
-
*/
|
|
296
|
-
static LONGEST_MATCH: number;
|
|
297
|
-
/**
|
|
298
|
-
* Flag: enable linear-time captureless lookbehinds.
|
|
299
|
-
*/
|
|
300
|
-
static LOOKBEHINDS: number;
|
|
301
|
-
/**
|
|
302
|
-
* Returns a literal pattern string for the specified string.
|
|
303
|
-
*
|
|
304
|
-
* This method produces a string that can be used to create a <code>RE2JS</code> that would
|
|
305
|
-
* match the string <code>s</code> as if it were a literal pattern.
|
|
306
|
-
*
|
|
307
|
-
* Metacharacters or escape sequences in the input sequence will be given no special meaning.
|
|
308
|
-
*
|
|
309
|
-
* @param {string} str The string to be literalized
|
|
310
|
-
* @returns {string} A literal string replacement
|
|
311
|
-
*/
|
|
312
|
-
static quote(str: string): string;
|
|
313
|
-
/**
|
|
314
|
-
* Quotes '\' and '$' in {@code str}, so that the returned string could be used in
|
|
315
|
-
* replacement methods as a literal replacement of {@code str}.
|
|
316
|
-
*
|
|
317
|
-
* This is a convenience delegation to {@link Matcher.quoteReplacement}.
|
|
318
|
-
*
|
|
319
|
-
* @param {string} str the string to be quoted
|
|
320
|
-
* @param {boolean} [javaMode=false] whether the replacement will be used in javaMode
|
|
321
|
-
* @returns {string} the quoted string
|
|
322
|
-
*/
|
|
323
|
-
static quoteReplacement(str: string, javaMode?: boolean): string;
|
|
324
|
-
/**
|
|
325
|
-
* Translates a given regular expression string to ensure compatibility with RE2JS.
|
|
326
|
-
*
|
|
327
|
-
* This function preprocesses the input regex string by applying necessary transformations,
|
|
328
|
-
* such as escaping special characters (e.g., `/`), converting named capture groups to
|
|
329
|
-
* RE2JS-compatible syntax, and handling Unicode sequences properly. It ensures that the
|
|
330
|
-
* resulting regex is safe and properly formatted before compilation.
|
|
331
|
-
*
|
|
332
|
-
* @param {string|RegExp} expr - The regular expression string to be translated.
|
|
333
|
-
* @returns {string} - The transformed regular expression string, ready for compilation.
|
|
334
|
-
*/
|
|
335
|
-
static translateRegExp(expr: string | RegExp): string;
|
|
336
|
-
/**
|
|
337
|
-
* Helper: create new RE2JS with given regex and flags. Flregex is the regex with flags applied.
|
|
338
|
-
* @param {string} regex
|
|
339
|
-
* @param {number} [flags=0]
|
|
340
|
-
* @returns {RE2JS}
|
|
341
|
-
*/
|
|
342
|
-
static compile(regex: string, flags?: number): RE2JS;
|
|
343
|
-
/**
|
|
344
|
-
* Matches a string against a regular expression.
|
|
345
|
-
*
|
|
346
|
-
* @param {string} regex the regular expression
|
|
347
|
-
* @param {string|number[]|Uint8Array} input the input
|
|
348
|
-
* @returns {boolean} true if the regular expression matches the entire input
|
|
349
|
-
* @throws RE2JSSyntaxException if the regular expression is malformed
|
|
350
|
-
*/
|
|
351
|
-
static matches(regex: string, input: string | number[] | Uint8Array): boolean;
|
|
352
|
-
/**
|
|
353
|
-
* This is visible for testing.
|
|
354
|
-
* @private
|
|
355
|
-
*/
|
|
356
|
-
private static initTest;
|
|
357
|
-
/**
|
|
358
|
-
*
|
|
359
|
-
* @param {string} pattern
|
|
360
|
-
* @param {number} flags
|
|
361
|
-
*/
|
|
362
|
-
constructor(pattern: string, flags: number);
|
|
363
|
-
patternInput: string;
|
|
364
|
-
flagsInput: number;
|
|
365
|
-
/**
|
|
366
|
-
* Releases memory used by internal caches associated with this pattern. Does not change the
|
|
367
|
-
* observable behaviour. Useful for tests that detect memory leaks via allocation tracking.
|
|
368
|
-
*/
|
|
369
|
-
reset(): void;
|
|
370
|
-
/**
|
|
371
|
-
* Returns the flags used in the constructor.
|
|
372
|
-
* @returns {number}
|
|
373
|
-
*/
|
|
374
|
-
flags(): number;
|
|
375
|
-
/**
|
|
376
|
-
* Returns the pattern used in the constructor.
|
|
377
|
-
* @returns {string}
|
|
378
|
-
*/
|
|
379
|
-
pattern(): string;
|
|
380
|
-
re2(): any;
|
|
381
|
-
/**
|
|
382
|
-
* Matches a string against a regular expression.
|
|
383
|
-
*
|
|
384
|
-
* @param {string|number[]|Uint8Array} input the input
|
|
385
|
-
* @returns {boolean} true if the regular expression matches the entire input
|
|
386
|
-
*/
|
|
387
|
-
matches(input: string | number[] | Uint8Array): boolean;
|
|
388
|
-
/**
|
|
389
|
-
* Creates a new {@code Matcher} matching the pattern against the input.
|
|
390
|
-
*
|
|
391
|
-
* @param {string|number[]|Uint8Array} input the input string
|
|
392
|
-
* @returns {Matcher}
|
|
393
|
-
*/
|
|
394
|
-
matcher(input: string | number[] | Uint8Array): Matcher;
|
|
395
|
-
/**
|
|
396
|
-
* Tests whether the regular expression matches any part of the input string.
|
|
397
|
-
* Performance Note: This method is highly optimized. Because it only returns
|
|
398
|
-
* a boolean and does not extract capture groups, it bypasses the `Matcher` overhead
|
|
399
|
-
* and guarantees execution on the high-speed DFA engine whenever possible.
|
|
400
|
-
*
|
|
401
|
-
* @param {string|number[]|Uint8Array} input - The input string or UTF-8 byte array to test against.
|
|
402
|
-
* @returns {boolean} `true` if the pattern is found anywhere in the input, `false` otherwise.
|
|
403
|
-
*/
|
|
404
|
-
test(input: string | number[] | Uint8Array): boolean;
|
|
405
|
-
/**
|
|
406
|
-
* Tests whether the regular expression matches the ENTIRE input string.
|
|
407
|
-
* * **Performance Note:** This operates identically to `.matches()`, but is significantly
|
|
408
|
-
* faster because it does not request capture group data. By requesting 0 capture groups,
|
|
409
|
-
* it securely routes execution through the DFA fast-path.
|
|
410
|
-
*
|
|
411
|
-
* @param {string|number[]|Uint8Array} input - The input string or UTF-8 byte array to test against.
|
|
412
|
-
* @returns {boolean} `true` if the exact input string fully matches the pattern, `false` otherwise.
|
|
413
|
-
*/
|
|
414
|
-
testExact(input: string | number[] | Uint8Array): boolean;
|
|
415
|
-
/**
|
|
416
|
-
* Splits input around instances of the regular expression. It returns an array giving the strings
|
|
417
|
-
* that occur before, between, and after instances of the regular expression.
|
|
418
|
-
*
|
|
419
|
-
* If {@code limit <= 0}, there is no limit on the size of the returned array. If
|
|
420
|
-
* {@code limit == 0}, empty strings that would occur at the end of the array are omitted. If
|
|
421
|
-
* {@code limit > 0}, at most limit strings are returned. The final string contains the remainder
|
|
422
|
-
* of the input, possibly including additional matches of the pattern.
|
|
423
|
-
*
|
|
424
|
-
* @param {string} input the input string to be split
|
|
425
|
-
* @param {number} [limit=0] the limit
|
|
426
|
-
* @returns {string[]} the split strings
|
|
427
|
-
*/
|
|
428
|
-
split(input: string, limit?: number): string[];
|
|
429
|
-
/**
|
|
430
|
-
* Returns an iterator of all results matching a string against the regular expression,
|
|
431
|
-
* including capturing groups.
|
|
432
|
-
*
|
|
433
|
-
* @param {string|number[]|Uint8Array} input the input string or byte array
|
|
434
|
-
* @returns {IterableIterator<Array>}
|
|
435
|
-
*/
|
|
436
|
-
matchAll(input: string | number[] | Uint8Array): IterableIterator<any[]>;
|
|
437
|
-
/**
|
|
438
|
-
*
|
|
439
|
-
* @returns {string}
|
|
440
|
-
*/
|
|
441
|
-
toString(): string;
|
|
442
|
-
/**
|
|
443
|
-
* Returns the program size of this pattern.
|
|
444
|
-
*
|
|
445
|
-
* <p>
|
|
446
|
-
* Similar to the C++ implementation, the program size is a very approximate measure of a regexp's
|
|
447
|
-
* "cost". Larger numbers are more expensive than smaller numbers.
|
|
448
|
-
* </p>
|
|
449
|
-
*
|
|
450
|
-
* @returns {number} the program size of this pattern
|
|
451
|
-
*/
|
|
452
|
-
programSize(): number;
|
|
453
|
-
/**
|
|
454
|
-
* Returns the number of capturing groups in this matcher's pattern. Group zero denotes the entire
|
|
455
|
-
* pattern and is excluded from this count.
|
|
456
|
-
*
|
|
457
|
-
* @returns {number} the number of capturing groups in this pattern
|
|
458
|
-
*/
|
|
459
|
-
groupCount(): number;
|
|
460
|
-
/**
|
|
461
|
-
* Return a map of the capturing groups in this matcher's pattern, where key is the name and value
|
|
462
|
-
* is the index of the group in the pattern.
|
|
463
|
-
* @returns {Record<string, number>}
|
|
464
|
-
*/
|
|
465
|
-
namedGroups(): Record<string, number>;
|
|
466
|
-
/**
|
|
467
|
-
*
|
|
468
|
-
* @param {*} other
|
|
469
|
-
* @returns {boolean}
|
|
470
|
-
*/
|
|
471
|
-
equals(other: any): boolean;
|
|
472
|
-
}
|
|
473
|
-
/**
|
|
474
|
-
* An exception thrown by the compiler
|
|
475
|
-
*/
|
|
476
|
-
export class RE2JSCompileException extends RE2JSException {
|
|
477
|
-
}
|
|
478
|
-
export class RE2JSException extends Error {
|
|
479
|
-
/** @param {string} message */
|
|
480
|
-
constructor(message: string);
|
|
481
|
-
}
|
|
482
|
-
/**
|
|
483
|
-
* An exception thrown by flags
|
|
484
|
-
*/
|
|
485
|
-
export class RE2JSFlagsException extends RE2JSException {
|
|
486
|
-
}
|
|
487
|
-
/**
|
|
488
|
-
* An exception thrown by using groups
|
|
489
|
-
*/
|
|
490
|
-
export class RE2JSGroupException extends RE2JSException {
|
|
491
|
-
}
|
|
492
|
-
/**
|
|
493
|
-
* An exception thrown for internal engine errors, such as corrupted bytecodes.
|
|
494
|
-
*/
|
|
495
|
-
export class RE2JSInternalException extends RE2JSException {
|
|
496
|
-
}
|
|
497
|
-
/**
|
|
498
|
-
* An exception thrown by the parser if the pattern was invalid.
|
|
499
|
-
*/
|
|
500
|
-
export class RE2JSSyntaxException extends RE2JSException {
|
|
501
|
-
/**
|
|
502
|
-
* @param {string} error
|
|
503
|
-
* @param {string|null} [input=null]
|
|
504
|
-
*/
|
|
505
|
-
constructor(error: string, input?: string | null);
|
|
506
|
-
/** @type {string} */
|
|
507
|
-
error: string;
|
|
508
|
-
/** @type {string|null} */
|
|
509
|
-
input: string | null;
|
|
510
|
-
/**
|
|
511
|
-
* Retrieves the description of the error.
|
|
512
|
-
* @returns {string}
|
|
513
|
-
*/
|
|
514
|
-
getDescription(): string;
|
|
515
|
-
/**
|
|
516
|
-
* Retrieves the erroneous regular-expression pattern.
|
|
517
|
-
* @returns {string|null}
|
|
518
|
-
*/
|
|
519
|
-
getPattern(): string | null;
|
|
520
|
-
}
|
|
521
|
-
export class RE2Set {
|
|
522
|
-
/** @type {number} */
|
|
523
|
-
static UNANCHORED: number;
|
|
524
|
-
/** @type {number} */
|
|
525
|
-
static ANCHOR_START: number;
|
|
526
|
-
/** @type {number} */
|
|
527
|
-
static ANCHOR_BOTH: number;
|
|
528
|
-
/**
|
|
529
|
-
* Constructs a new RE2Set with the specified anchor mode and flags.
|
|
530
|
-
* @param {number} [anchor=RE2Set.UNANCHORED] - The anchoring mode (e.g., RE2Set.UNANCHORED).
|
|
531
|
-
* @param {number} [flags=0] - The public flags to apply to all patterns in the set.
|
|
532
|
-
*/
|
|
533
|
-
constructor(anchor?: number, flags?: number);
|
|
534
|
-
anchor: number;
|
|
535
|
-
jsFlags: number;
|
|
536
|
-
re2Flags: number;
|
|
537
|
-
regexps: any[];
|
|
538
|
-
prog: Prog | null;
|
|
539
|
-
dfa: DFA | null;
|
|
540
|
-
dummyRe2: {
|
|
541
|
-
prog: Prog;
|
|
542
|
-
cond: number;
|
|
543
|
-
prefix: string;
|
|
544
|
-
prefixRune: number;
|
|
545
|
-
longest: boolean;
|
|
546
|
-
} | null;
|
|
547
|
-
/**
|
|
548
|
-
* Adds a new regular expression pattern to the set.
|
|
549
|
-
* Patterns cannot be added after the set has been compiled.
|
|
550
|
-
* @param {string} pattern - The regular expression pattern to add.
|
|
551
|
-
* @returns {number} The integer index assigned to the added pattern.
|
|
552
|
-
* @throws {RE2JSCompileException} If patterns are added after compilation.
|
|
553
|
-
*/
|
|
554
|
-
add(pattern: string): number;
|
|
555
|
-
/**
|
|
556
|
-
* Compiles the added patterns into a single state machine.
|
|
557
|
-
* This is automatically called on the first match if not called explicitly.
|
|
558
|
-
* @returns {void}
|
|
559
|
-
*/
|
|
560
|
-
compile(): void;
|
|
561
|
-
/**
|
|
562
|
-
* Matches the input against the compiled set of regular expressions.
|
|
563
|
-
* @param {string|number[]|Uint8Array} input - The input string or UTF-8 byte array to match against.
|
|
564
|
-
* @returns {number[]} An array of indices representing the patterns that successfully matched the input.
|
|
565
|
-
*/
|
|
566
|
-
match(input: string | number[] | Uint8Array): number[];
|
|
567
|
-
}
|
|
568
|
-
export function re(stringsOrFlags: any, ...values: any[]): RE2JS | ((strings: any, ...tagValues: any[]) => RE2JS);
|
|
569
|
-
/**
|
|
570
|
-
* Abstract the representations of input text supplied to Matcher.
|
|
571
|
-
*/
|
|
572
|
-
declare class MatcherInputBase {
|
|
573
|
-
static Encoding: any;
|
|
574
|
-
getEncoding(): void;
|
|
575
|
-
/**
|
|
576
|
-
*
|
|
577
|
-
* @returns {boolean}
|
|
578
|
-
*/
|
|
579
|
-
isUTF8Encoding(): boolean;
|
|
580
|
-
/**
|
|
581
|
-
*
|
|
582
|
-
* @returns {boolean}
|
|
583
|
-
*/
|
|
584
|
-
isUTF16Encoding(): boolean;
|
|
585
|
-
}
|
|
586
|
-
/**
|
|
587
|
-
* A Prog is a compiled regular expression program.
|
|
588
|
-
*/
|
|
589
|
-
declare class Prog {
|
|
590
|
-
inst: any[];
|
|
591
|
-
start: number;
|
|
592
|
-
numCap: number;
|
|
593
|
-
lbStarts: any[];
|
|
594
|
-
numLb: number;
|
|
595
|
-
getInst(pc: any): any;
|
|
596
|
-
numInst(): number;
|
|
597
|
-
addInst(op: any): void;
|
|
598
|
-
skipNop(pc: any): any;
|
|
599
|
-
prefix(): (string | boolean)[];
|
|
600
|
-
startCond(): number;
|
|
601
|
-
patch(l: any, val: any): void;
|
|
602
|
-
append(l1: any, l2: any): any;
|
|
603
|
-
/**
|
|
604
|
-
*
|
|
605
|
-
* @returns {string}
|
|
606
|
-
*/
|
|
607
|
-
toString(): string;
|
|
608
|
-
}
|
|
609
|
-
declare class DFA {
|
|
610
|
-
static MAX_CACHE_CLEARS: number;
|
|
611
|
-
constructor(prog: any);
|
|
612
|
-
prog: any;
|
|
613
|
-
stateCache: Map<any, any>;
|
|
614
|
-
stateCount: number;
|
|
615
|
-
startState: any;
|
|
616
|
-
stateLimit: number;
|
|
617
|
-
cacheClears: number;
|
|
618
|
-
failed: boolean;
|
|
619
|
-
clock: number;
|
|
620
|
-
computeClosure(pcs: any): {
|
|
621
|
-
pcs: Int32Array<ArrayBuffer>;
|
|
622
|
-
isMatch: boolean;
|
|
623
|
-
matchIDs: any[];
|
|
624
|
-
} | null;
|
|
625
|
-
getState(pcs: any): any;
|
|
626
|
-
evictCache(): void;
|
|
627
|
-
step(state: any, charCode: any, anchor: any): any;
|
|
628
|
-
match(input: any, pos: any, anchor: any): boolean | null;
|
|
629
|
-
matchSet(input: any, pos: any, anchor: any): any[] | null;
|
|
630
|
-
}
|
|
631
|
-
export {};
|
|
632
|
-
//# sourceMappingURL=index.esm.d.ts.map
|
package/build/index.esm.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.d.ts","sourceRoot":"","sources":["index.esm.js"],"names":[],"mappings":"AA22CA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH;IACE;;;;OAIG;IACH,iCAAiC;IAEjC;;;;;;;OAOG;IACH,6BAJW,MAAM,aACN,OAAO,GACL,MAAM,CA2BlB;IACD;;;;OAIG;IACH,qBAHW,KAAK,SACL,MAAM,GAAC,MAAM,EAAE,GAAC,UAAU,EA6BpC;IAvBC;;;OAGG;IACH,cAFU,KAAK,CAEY;IAG3B,qBAAqB;IACrB,mBADW,MAAM,CACqC;IAEtD,uBAAuB;IACvB,QADW,MAAM,EAAE,CACH;IAChB,qCAAqC;IACrC,aADW,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CACC;IAClC,qBAAqB;IACrB,sBADW,MAAM,CACqC;IAUxD;;;OAGG;IACH,WAFa,KAAK,CAIjB;IAED;;;;OAIG;IACH,SAFa,OAAO,CAiBnB;IAbC,qBAAqB;IACrB,uCAAoD;IAEpD,qBAAqB;IACrB,8BAAkB;IAElB,8BAAqB;IAGrB,+BAAsB;IAEtB,+BAAmB;IAIrB;;;;OAIG;IACH,yBAHW,gBAAgB,GACd,OAAO,CASnB;IAHC,2CAAyB;IAK3B;;;;;OAKG;IACH,cAHW,MAAM,GAAC,MAAM,GACX,MAAM,CAYlB;IAED;;;;;OAKG;IACH,YAHW,M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