re2js 0.3.1 → 0.3.3
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/README.md +24 -0
- package/build/index.cjs.cjs +99 -22
- package/build/index.cjs.cjs.map +1 -1
- package/build/index.esm.d.ts +125 -36
- package/build/index.esm.d.ts.map +1 -1
- package/build/index.esm.js +99 -22
- package/build/index.esm.js.map +1 -1
- package/build/index.umd.js +99 -22
- package/build/index.umd.js.map +1 -1
- package/package.json +18 -18
package/build/index.esm.d.ts
CHANGED
|
@@ -47,7 +47,7 @@ export class RE2JS {
|
|
|
47
47
|
/**
|
|
48
48
|
* Helper: create new RE2JS with given regex and flags. Flregex is the regex with flags applied.
|
|
49
49
|
* @param {string} regex
|
|
50
|
-
* @param {number} flags
|
|
50
|
+
* @param {number} [flags=0]
|
|
51
51
|
* @returns {RE2JS}
|
|
52
52
|
*/
|
|
53
53
|
static compile(regex: string, ...args: any[]): RE2JS;
|
|
@@ -55,15 +55,24 @@ export class RE2JS {
|
|
|
55
55
|
* Matches a string against a regular expression.
|
|
56
56
|
*
|
|
57
57
|
* @param {string} regex the regular expression
|
|
58
|
-
* @param {
|
|
58
|
+
* @param {string|number[]} input the input
|
|
59
59
|
* @returns {boolean} true if the regular expression matches the entire input
|
|
60
60
|
* @throws RE2JSSyntaxException if the regular expression is malformed
|
|
61
61
|
*/
|
|
62
|
-
static matches(regex: string, input:
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
static matches(regex: string, input: string | number[]): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* This is visible for testing.
|
|
65
|
+
* @private
|
|
66
|
+
*/
|
|
67
|
+
private static initTest;
|
|
68
|
+
/**
|
|
69
|
+
*
|
|
70
|
+
* @param {string} pattern
|
|
71
|
+
* @param {number} flags
|
|
72
|
+
*/
|
|
73
|
+
constructor(pattern: string, flags: number);
|
|
74
|
+
patternInput: string;
|
|
75
|
+
flagsInput: number;
|
|
67
76
|
/**
|
|
68
77
|
* Releases memory used by internal caches associated with this pattern. Does not change the
|
|
69
78
|
* observable behaviour. Useful for tests that detect memory leaks via allocation tracking.
|
|
@@ -83,17 +92,17 @@ export class RE2JS {
|
|
|
83
92
|
/**
|
|
84
93
|
* Matches a string against a regular expression.
|
|
85
94
|
*
|
|
86
|
-
* @param {
|
|
95
|
+
* @param {string|number[]} input the input
|
|
87
96
|
* @returns {boolean} true if the regular expression matches the entire input
|
|
88
97
|
*/
|
|
89
|
-
matches(input:
|
|
98
|
+
matches(input: string | number[]): boolean;
|
|
90
99
|
/**
|
|
91
100
|
* Creates a new {@code Matcher} matching the pattern against the input.
|
|
92
101
|
*
|
|
93
|
-
* @param {
|
|
102
|
+
* @param {string|number[]} input the input string
|
|
94
103
|
* @returns {Matcher}
|
|
95
104
|
*/
|
|
96
|
-
matcher(input:
|
|
105
|
+
matcher(input: string | number[]): Matcher;
|
|
97
106
|
/**
|
|
98
107
|
* Splits input around instances of the regular expression. It returns an array giving the strings
|
|
99
108
|
* that occur before, between, and after instances of the regular expression.
|
|
@@ -105,11 +114,15 @@ export class RE2JS {
|
|
|
105
114
|
* of the input, possibly including additional matches of the pattern.
|
|
106
115
|
*
|
|
107
116
|
* @param {string} input the input string to be split
|
|
108
|
-
* @param {number} limit the limit
|
|
109
|
-
* @returns {
|
|
117
|
+
* @param {number} [limit=0] the limit
|
|
118
|
+
* @returns {string[]} the split strings
|
|
110
119
|
*/
|
|
111
|
-
split(input: string, ...args: any[]):
|
|
112
|
-
|
|
120
|
+
split(input: string, ...args: any[]): string[];
|
|
121
|
+
/**
|
|
122
|
+
*
|
|
123
|
+
* @returns {string}
|
|
124
|
+
*/
|
|
125
|
+
toString(): string;
|
|
113
126
|
/**
|
|
114
127
|
* Returns the number of capturing groups in this matcher's pattern. Group zero denotes the entire
|
|
115
128
|
* pattern and is excluded from this count.
|
|
@@ -123,6 +136,11 @@ export class RE2JS {
|
|
|
123
136
|
* @returns {*}
|
|
124
137
|
*/
|
|
125
138
|
namedGroups(): any;
|
|
139
|
+
/**
|
|
140
|
+
*
|
|
141
|
+
* @param {*} other
|
|
142
|
+
* @returns {boolean}
|
|
143
|
+
*/
|
|
126
144
|
equals(other: any): boolean;
|
|
127
145
|
}
|
|
128
146
|
/**
|
|
@@ -187,49 +205,60 @@ declare class Matcher {
|
|
|
187
205
|
* Quotes '\' and '$' in {@code s}, so that the returned string could be used in
|
|
188
206
|
* {@link #appendReplacement} as a literal replacement of {@code s}.
|
|
189
207
|
*
|
|
190
|
-
* @param {string}
|
|
208
|
+
* @param {string} str the string to be quoted
|
|
191
209
|
* @returns {string} the quoted string
|
|
192
210
|
*/
|
|
193
|
-
static quoteReplacement(str:
|
|
194
|
-
|
|
195
|
-
|
|
211
|
+
static quoteReplacement(str: string): string;
|
|
212
|
+
/**
|
|
213
|
+
*
|
|
214
|
+
* @param {RE2JS} pattern
|
|
215
|
+
* @param {Utf8MatcherInput|Utf16MatcherInput|number[]|string} input
|
|
216
|
+
*/
|
|
217
|
+
constructor(pattern: RE2JS, input: Utf8MatcherInput | Utf16MatcherInput | number[] | string);
|
|
218
|
+
patternInput: RE2JS;
|
|
196
219
|
patternGroupCount: any;
|
|
197
220
|
groups: any[];
|
|
198
221
|
namedGroups: any;
|
|
199
|
-
/**
|
|
200
|
-
|
|
222
|
+
/**
|
|
223
|
+
* Returns the {@code RE2JS} associated with this {@code Matcher}.
|
|
224
|
+
* @returns {RE2JS}
|
|
225
|
+
*/
|
|
226
|
+
pattern(): RE2JS;
|
|
201
227
|
/**
|
|
202
228
|
* Resets the {@code Matcher}, rewinding input and discarding any match information.
|
|
203
229
|
*
|
|
204
|
-
* @returns the {@code Matcher} itself, for chained method calls
|
|
230
|
+
* @returns {Matcher} the {@code Matcher} itself, for chained method calls
|
|
205
231
|
*/
|
|
206
|
-
reset():
|
|
232
|
+
reset(): Matcher;
|
|
207
233
|
matcherInputLength: any;
|
|
208
|
-
appendPos:
|
|
234
|
+
appendPos: string | number;
|
|
209
235
|
hasMatch: boolean;
|
|
210
236
|
hasGroups: boolean;
|
|
211
237
|
anchorFlag: number;
|
|
212
238
|
/**
|
|
213
239
|
* Resets the {@code Matcher} and changes the input.
|
|
214
|
-
* @returns the {@code Matcher} itself, for chained method calls
|
|
240
|
+
* @returns {Matcher} the {@code Matcher} itself, for chained method calls
|
|
215
241
|
*/
|
|
216
|
-
resetMatcherInput(input: any):
|
|
242
|
+
resetMatcherInput(input: any): Matcher;
|
|
217
243
|
matcherInput: any;
|
|
218
244
|
/**
|
|
219
245
|
* Returns the start of the named group of the most recent match, or -1 if the group was not
|
|
220
246
|
* matched.
|
|
221
|
-
*
|
|
247
|
+
* @param {string|number} [group=0]
|
|
248
|
+
* @returns {string}
|
|
222
249
|
*/
|
|
223
|
-
start(...args: any[]):
|
|
250
|
+
start(...args: any[]): string;
|
|
224
251
|
/**
|
|
225
252
|
* Returns the end of the named group of the most recent match, or -1 if the group was not
|
|
226
253
|
* matched.
|
|
227
|
-
*
|
|
254
|
+
* @param {string|number} [group=0]
|
|
255
|
+
* @returns {string}
|
|
228
256
|
*/
|
|
229
|
-
end(...args: any[]):
|
|
257
|
+
end(...args: any[]): string;
|
|
230
258
|
/**
|
|
231
259
|
* Returns the named group of the most recent match, or {@code null} if the group was not matched.
|
|
232
|
-
*
|
|
260
|
+
* @param {string|number} [group=0]
|
|
261
|
+
* @returns {string}
|
|
233
262
|
*/
|
|
234
263
|
group(...args: any[]): string;
|
|
235
264
|
/**
|
|
@@ -262,7 +291,7 @@ declare class Matcher {
|
|
|
262
291
|
* Matches the input against the pattern (unanchored), starting at a specified position. If there
|
|
263
292
|
* is a match, {@code find} sets the match state to describe it.
|
|
264
293
|
*
|
|
265
|
-
* @param start the input position where the search begins
|
|
294
|
+
* @param {string|number} [start=null] the input position where the search begins
|
|
266
295
|
* @returns {boolean} if it finds a match
|
|
267
296
|
* @throws IndexOutOfBoundsException if start is not a valid input position
|
|
268
297
|
*/
|
|
@@ -305,21 +334,24 @@ declare class Matcher {
|
|
|
305
334
|
*
|
|
306
335
|
* @param {string} replacement the replacement string
|
|
307
336
|
* @param {boolean} [perlMode=false] activate perl/js mode (different behaviour for capture groups and special characters)
|
|
308
|
-
* @returns
|
|
337
|
+
* @returns {string}
|
|
309
338
|
* @throws IllegalStateException if there was no most recent match
|
|
310
339
|
* @throws IndexOutOfBoundsException if replacement refers to an invalid group
|
|
340
|
+
* @private
|
|
311
341
|
*/
|
|
312
|
-
appendReplacement
|
|
342
|
+
private appendReplacement;
|
|
313
343
|
/**
|
|
314
344
|
* @param {string} replacement - the replacement string
|
|
315
345
|
* @returns {string}
|
|
346
|
+
* @private
|
|
316
347
|
*/
|
|
317
|
-
appendReplacementInternal
|
|
348
|
+
private appendReplacementInternal;
|
|
318
349
|
/**
|
|
319
350
|
* @param {string} replacement - the replacement string
|
|
320
351
|
* @returns {string}
|
|
352
|
+
* @private
|
|
321
353
|
*/
|
|
322
|
-
appendReplacementInternalPerl
|
|
354
|
+
private appendReplacementInternalPerl;
|
|
323
355
|
/**
|
|
324
356
|
* Return the substring of the input from the append position to the end of the
|
|
325
357
|
* input.
|
|
@@ -356,5 +388,62 @@ declare class Matcher {
|
|
|
356
388
|
*/
|
|
357
389
|
private replace;
|
|
358
390
|
}
|
|
391
|
+
declare class Utf8MatcherInput extends MatcherInputBase {
|
|
392
|
+
constructor(...args: any[]);
|
|
393
|
+
bytes: any;
|
|
394
|
+
getEncoding(): any;
|
|
395
|
+
/**
|
|
396
|
+
*
|
|
397
|
+
* @returns {string}
|
|
398
|
+
*/
|
|
399
|
+
asCharSequence(): string;
|
|
400
|
+
/**
|
|
401
|
+
*
|
|
402
|
+
* @returns {number[]}
|
|
403
|
+
*/
|
|
404
|
+
asBytes(): number[];
|
|
405
|
+
/**
|
|
406
|
+
*
|
|
407
|
+
* @returns {number}
|
|
408
|
+
*/
|
|
409
|
+
length(): number;
|
|
410
|
+
}
|
|
411
|
+
declare class Utf16MatcherInput extends MatcherInputBase {
|
|
412
|
+
constructor(...args: any[]);
|
|
413
|
+
charSequence: any;
|
|
414
|
+
getEncoding(): any;
|
|
415
|
+
/**
|
|
416
|
+
*
|
|
417
|
+
* @returns {string}
|
|
418
|
+
*/
|
|
419
|
+
asCharSequence(): string;
|
|
420
|
+
/**
|
|
421
|
+
*
|
|
422
|
+
* @returns {number[]}
|
|
423
|
+
*/
|
|
424
|
+
asBytes(): number[];
|
|
425
|
+
/**
|
|
426
|
+
*
|
|
427
|
+
* @returns {number}
|
|
428
|
+
*/
|
|
429
|
+
length(): number;
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Abstract the representations of input text supplied to Matcher.
|
|
433
|
+
*/
|
|
434
|
+
declare class MatcherInputBase {
|
|
435
|
+
static Encoding: Readonly<{}>;
|
|
436
|
+
getEncoding(): void;
|
|
437
|
+
/**
|
|
438
|
+
*
|
|
439
|
+
* @returns {boolean}
|
|
440
|
+
*/
|
|
441
|
+
isUTF8Encoding(): boolean;
|
|
442
|
+
/**
|
|
443
|
+
*
|
|
444
|
+
* @returns {boolean}
|
|
445
|
+
*/
|
|
446
|
+
isUTF16Encoding(): boolean;
|
|
447
|
+
}
|
|
359
448
|
export {};
|
|
360
449
|
//# sourceMappingURL=index.esm.d.ts.map
|
package/build/index.esm.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.d.ts","sourceRoot":"","sources":["index.esm.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.esm.d.ts","sourceRoot":"","sources":["index.esm.js"],"names":[],"mappings":"AA27KA;;;;;;;;;;GAUG;AACH;IACE;;OAEG;IACH,gCAA4B;IAC5B;;OAEG;IACH,sBAAkB;IAClB;;;OAGG;IACH,yBAAqB;IACrB;;OAEG;IACH,sCAAkC;IAClC;;OAEG;IACH,6BAA0B;IAE1B;;;;;;;;;;;OAWG;IACH,kBAHW,MAAM,GACJ,MAAM,CAIlB;IAED;;;;;OAKG;IACH,sBA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