rregex 1.13.2 → 2.0.0

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/lib/core.d.mts ADDED
@@ -0,0 +1,1287 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * Escapes all regular expression meta characters in `text`.
5
+ *
6
+ * The string returned may be safely used as a literal in a regular
7
+ * expression.
8
+ */
9
+ export declare function escape(text: string): string;
10
+ /**
11
+ * Represents a single match of a regex in a haystack.
12
+ *
13
+ * A `Match` contains both the start and end byte offsets of the match and the
14
+ * actual substring corresponding to the range of those byte offsets. It is
15
+ * guaranteed that `start <= end`. When `start == end`, the match is empty.
16
+ *
17
+ * Since this `Match` can only be produced by the top-level `Regex` APIs
18
+ * that only support searching UTF-8 encoded strings, the byte offsets for a
19
+ * `Match` are guaranteed to fall on valid UTF-8 codepoint boundaries. That
20
+ * is, slicing an `Uint8Array` created with a TextEncoder is guaranteed to never
21
+ * be out of range.
22
+ *
23
+ * # Numbering
24
+ *
25
+ * The byte offsets in a `Match` form a half-open interval. That is, the
26
+ * start of the range is inclusive and the end of the range is exclusive.
27
+ * For example, given a haystack `abcFOOxyz` and a match of `FOO`, its byte
28
+ * offset range starts at `3` and ends at `6`. `3` corresponds to `F` and
29
+ * `6` corresponds to `x`, which is one past the end of the match. This
30
+ * corresponds to the same kind of slicing that Rust uses.
31
+ *
32
+ * For more on why this was chosen over other schemes (aside from being
33
+ * consistent with how Rust the language works), see [this discussion] and
34
+ * [Dijkstra's note on a related topic][note].
35
+ *
36
+ * [this discussion]: https://github.com/rust-lang/regex/discussions/866
37
+ * [note]: https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html
38
+ *
39
+ * # Example
40
+ *
41
+ * This example shows the value of each of the methods on `Match` for a
42
+ * particular search.
43
+ *
44
+ * ```typescript
45
+ * import { RRegex } from "rregex"
46
+ *
47
+ * const re = new RRegex("\\p{Greek}+");
48
+ * const hay = "Greek: αβγδ";
49
+ * const m = re.find(hay);
50
+ * expect(m.start).toBe(7);
51
+ * expect(m.end).toBe(15);
52
+ * expect(m.value).toBe("αβγδ");
53
+ * ```
54
+ *
55
+ * @see @see https://docs.rs/regex/latest/regex/
56
+ */
57
+ export type Match = {
58
+ start: number;
59
+ end: number;
60
+ value: string;
61
+ };
62
+ /**
63
+ * A high-level intermediate representation (HIR) for a regular expression.
64
+ */
65
+ export type Hir = {
66
+ '@type': 'struct';
67
+ '@name': 'regex_syntax::hir::Hir';
68
+ kind: HirKind;
69
+ };
70
+ /**
71
+ * The underlying kind of an arbitrary `Hir` expression.
72
+ *
73
+ * An `HirKind` is principally useful for doing case analysis on the type of a
74
+ * regular expression. If you're looking to build new `Hir` values, then you must
75
+ * use the smart constructors defined on `Hir`, like `Hir::repetition`, to build
76
+ * new `Hir` values. The API intentionally does not expose any way of building an
77
+ * `Hir` directly from an `HirKind`.
78
+ */
79
+ export type HirKind = HirKindEmptyVariant | HirKindLiteralVariant | HirKindClassVariant | HirKindLookVariant | HirKindRepetitionVariant | HirKindCaptureVariant | HirKindConcatVariant | HirKindAlternationVariant;
80
+ /**
81
+ * The empty regular expression, which matches everything, including the empty string.
82
+ */
83
+ export type HirKindEmptyVariant = {
84
+ '@type': 'enum';
85
+ '@name': 'regex_syntax::hir::HirKind';
86
+ '@variant': 'Empty';
87
+ };
88
+ /**
89
+ * A literal string that matches exactly these bytes.
90
+ */
91
+ export type HirKindLiteralVariant = {
92
+ '@type': 'enum';
93
+ '@name': 'regex_syntax::hir::HirKind';
94
+ '@variant': 'Literal';
95
+ '@values': [Literal];
96
+ };
97
+ /**
98
+ * A single character class that matches any of the characters in the class.
99
+ * A class can either consist of Unicode scalar values as characters, or it can
100
+ * use bytes.
101
+ *
102
+ * A class may be empty. In which case, it matches nothing.
103
+ */
104
+ export type HirKindClassVariant = {
105
+ '@type': 'enum';
106
+ '@name': 'regex_syntax::hir::HirKind';
107
+ '@variant': 'Class';
108
+ '@values': [Class];
109
+ };
110
+ /**
111
+ * A look-around assertion. A look-around match always has zero length.
112
+ */
113
+ export type HirKindLookVariant = {
114
+ '@type': 'enum';
115
+ '@name': 'regex_syntax::hir::HirKind';
116
+ '@variant': 'Look';
117
+ '@values': [Look];
118
+ };
119
+ /**
120
+ * A repetition operation applied to a sub-expression.
121
+ */
122
+ export type HirKindRepetitionVariant = {
123
+ '@type': 'enum';
124
+ '@name': 'regex_syntax::hir::HirKind';
125
+ '@variant': 'Repetition';
126
+ '@values': [Repetition];
127
+ };
128
+ /**
129
+ * A capturing group, which contains a sub-expression.
130
+ */
131
+ export type HirKindCaptureVariant = {
132
+ '@type': 'enum';
133
+ '@name': 'regex_syntax::hir::HirKind';
134
+ '@variant': 'Capture';
135
+ '@values': [Capture];
136
+ };
137
+ /**
138
+ * A concatenation of expressions.
139
+ *
140
+ * A concatenation matches only if each of its sub-expressions match one after
141
+ * the other.
142
+ *
143
+ * Concatenations are guaranteed by `Hir`'s smart constructors to always have at
144
+ * least two sub-expressions.
145
+ */
146
+ export type HirKindConcatVariant = {
147
+ '@type': 'enum';
148
+ '@name': 'regex_syntax::hir::HirKind';
149
+ '@variant': 'Concat';
150
+ '@values': [Hir[]];
151
+ };
152
+ /**
153
+ * An alternation of expressions.
154
+ *
155
+ * An alternation matches only if at least one of its sub-expressions match.
156
+ * If multiple sub-expressions match, then the leftmost is preferred.
157
+ *
158
+ * Alternations are guaranteed by `Hir`'s smart constructors to always have at
159
+ * least two sub-expressions.
160
+ */
161
+ export type HirKindAlternationVariant = {
162
+ '@type': 'enum';
163
+ '@name': 'regex_syntax::hir::HirKind';
164
+ '@variant': 'Alternation';
165
+ '@values': [Hir[]];
166
+ };
167
+ /**
168
+ * The high-level intermediate representation of a literal.
169
+ *
170
+ * A literal corresponds to 0 or more bytes that should be matched literally.
171
+ * The smart constructors defined on `Hir` will automatically concatenate adjacent
172
+ * literals into one literal, and will even automatically replace empty literals
173
+ * with `HirKind::Empty`.
174
+ */
175
+ export type Literal = {
176
+ '@type': 'struct';
177
+ '@name': 'regex_syntax::hir::Literal';
178
+ '@values': [Uint8Array];
179
+ };
180
+ /**
181
+ * The high-level intermediate representation of a character class.
182
+ *
183
+ * A character class corresponds to a set of characters. A character is either
184
+ * defined by a Unicode scalar value or a byte. Unicode characters are used by
185
+ * default, while bytes are used when Unicode mode (via the `u` flag) is disabled.
186
+ *
187
+ * A character class, regardless of its character type, is represented by a
188
+ * sequence of non-overlapping non-adjacent ranges of characters.
189
+ *
190
+ * Note that `Bytes` variant may be produced even when it exclusively matches
191
+ * valid UTF-8. This is because a `Bytes` variant represents an intention by the
192
+ * author of the regular expression to disable Unicode mode, which in turn
193
+ * impacts the semantics of case insensitive matching. For example, `(?i)k` and
194
+ * `(?i-u)k` will not match the same set of strings.
195
+ */
196
+ export type Class = ClassUnicodeVariant | ClassByteVariant;
197
+ /**
198
+ * A set of characters represented by Unicode scalar values.
199
+ */
200
+ export type ClassUnicodeVariant = {
201
+ '@type': 'enum';
202
+ '@name': 'regex_syntax::hir::Class';
203
+ '@variant': 'Unicode';
204
+ '@values': [ClassUnicode];
205
+ };
206
+ /**
207
+ * A set of characters represented by arbitrary bytes (one byte per character).
208
+ */
209
+ export type ClassByteVariant = {
210
+ '@type': 'enum';
211
+ '@name': 'regex_syntax::hir::Class';
212
+ '@variant': 'Bytes';
213
+ '@values': [ClassBytes];
214
+ };
215
+ /**
216
+ * A set of characters represented by Unicode scalar values.
217
+ */
218
+ export type ClassUnicode = {
219
+ '@type': 'struct';
220
+ '@name': 'regex_syntax::hir::ClassUnicode';
221
+ /** The underlying ranges as a slice. */
222
+ ranges: ClassUnicodeRange[];
223
+ };
224
+ /**
225
+ * A single range of characters represented by Unicode scalar values.
226
+ *
227
+ * The range is closed. That is, the start and end of the range are included in
228
+ * the range.
229
+ */
230
+ export type ClassUnicodeRange = {
231
+ '@type': 'struct';
232
+ '@name': 'regex_syntax::hir::ClassUnicodeRange';
233
+ /**
234
+ * Return the start of this range.
235
+ *
236
+ * The start of a range is always less than or equal to the end of the range.
237
+ */
238
+ start: string;
239
+ /**
240
+ * Return the end of this range.
241
+ *
242
+ * The end of a range is always greater than or equal to the start of the range.
243
+ */
244
+ end: string;
245
+ /**
246
+ * The number of codepoints in this range.
247
+ */
248
+ len: number;
249
+ };
250
+ /**
251
+ * A set of characters represented by arbitrary bytes (where one byte corresponds
252
+ * to one character).
253
+ */
254
+ export type ClassBytes = {
255
+ '@type': 'struct';
256
+ '@name': 'regex_syntax::hir::ClassBytes';
257
+ /** The underlying ranges as a slice. */
258
+ ranges: ClassBytesRange[];
259
+ };
260
+ /**
261
+ * A single range of characters represented by arbitrary bytes.
262
+ *
263
+ * The range is closed. That is, the start and end of the range are included in
264
+ * the range.
265
+ */
266
+ export type ClassBytesRange = {
267
+ '@type': 'struct';
268
+ '@name': 'regex_syntax::hir::ClassBytesRange';
269
+ /**
270
+ * The start of this range.
271
+ *
272
+ * The start of a range is always less than or equal to the end of the range.
273
+ */
274
+ start: number;
275
+ /**
276
+ * The end of this range.
277
+ *
278
+ * The end of a range is always greater than or equal to the start of the range.
279
+ */
280
+ end: number;
281
+ /**
282
+ * The number of bytes in this range.
283
+ */
284
+ len: number;
285
+ };
286
+ /**
287
+ * The high-level intermediate representation for a look-around assertion.
288
+ *
289
+ * An assertion match is always zero-length. Also called an “empty match.”
290
+ */
291
+ export type Look = LookStartVariant | LookEndVariant | LookStartLFVariant | LookEndLFVariant | LookStartCRLFVariant | LookEndCRLFVariant | LookWordAsciiVariant | LookWordAsciiNegateVariant | LookWordUnicodeVariant | LookWordUnicodeNegateVariant | LookWordStartAsciiVariant | LookWordEndAsciiVariant | LookWordStartUnicodeVariant | LookWordEndUnicodeVariant | LookWordStartHalfAsciiVariant | LookWordEndHalfAsciiVariant | LookWordStartHalfUnicodeVariant | LookWordEndHalfUnicodeVariant;
292
+ /**
293
+ * Match the beginning of text. Specifically, this matches at the starting
294
+ * position of the input.
295
+ */
296
+ export type LookStartVariant = {
297
+ '@type': 'enum';
298
+ '@name': 'regex_syntax::hir:Look';
299
+ '@variant': 'Start';
300
+ };
301
+ /**
302
+ * Match the end of text. Specifically, this matches at the ending position of
303
+ * the input.
304
+ */
305
+ export type LookEndVariant = {
306
+ '@type': 'enum';
307
+ '@name': 'regex_syntax::hir:Look';
308
+ '@variant': 'End';
309
+ };
310
+ /**
311
+ * Match the beginning of a line or the beginning of text. Specifically, this
312
+ * matches at the starting position of the input, or at the position immediately
313
+ * following a `\n` character.
314
+ */
315
+ export type LookStartLFVariant = {
316
+ '@type': 'enum';
317
+ '@name': 'regex_syntax::hir:Look';
318
+ '@variant': 'StartLF';
319
+ };
320
+ /**
321
+ * Match the end of a line or the end of text. Specifically, this matches at the
322
+ * end position of the input, or at the position immediately preceding a `\n`
323
+ * character.
324
+ */
325
+ export type LookEndLFVariant = {
326
+ '@type': 'enum';
327
+ '@name': 'regex_syntax::hir:Look';
328
+ '@variant': 'EndLF';
329
+ };
330
+ /**
331
+ * Match the beginning of a line or the beginning of text. Specifically, this
332
+ * matches at the starting position of the input, or at the position immediately
333
+ * following either a `\r` or `\n` character, but never after a `\r` when a `\n`
334
+ * follows.
335
+ */
336
+ export type LookStartCRLFVariant = {
337
+ '@type': 'enum';
338
+ '@name': 'regex_syntax::hir:Look';
339
+ '@variant': 'StartCRLF';
340
+ };
341
+ /**
342
+ * Match the end of a line or the end of text. Specifically, this matches at the
343
+ * end position of the input, or at the position immediately preceding a `\r` or
344
+ * `\n` character, but never before a `\n` when a `\r` precedes it.
345
+ */
346
+ export type LookEndCRLFVariant = {
347
+ '@type': 'enum';
348
+ '@name': 'regex_syntax::hir:Look';
349
+ '@variant': 'EndCRLF';
350
+ };
351
+ /**
352
+ * Match an ASCII-only word boundary. That is, this matches a position where the
353
+ * left adjacent character and right adjacent character correspond to a word and
354
+ * non-word or a non-word and word character.
355
+ */
356
+ export type LookWordAsciiVariant = {
357
+ '@type': 'enum';
358
+ '@name': 'regex_syntax::hir:Look';
359
+ '@variant': 'WordAscii';
360
+ };
361
+ /**
362
+ * Match an ASCII-only negation of a word boundary.
363
+ */
364
+ export type LookWordAsciiNegateVariant = {
365
+ '@type': 'enum';
366
+ '@name': 'regex_syntax::hir:Look';
367
+ '@variant': 'WordAsciiNegate';
368
+ };
369
+ /**
370
+ * Match a Unicode-aware word boundary. That is, this matches a position where
371
+ * the left adjacent character and right adjacent character correspond to a word
372
+ * and non-word or a non-word and word character.
373
+ */
374
+ export type LookWordUnicodeVariant = {
375
+ '@type': 'enum';
376
+ '@name': 'regex_syntax::hir:Look';
377
+ '@variant': 'WordUnicode';
378
+ };
379
+ /**
380
+ * Match a Unicode-aware negation of a word boundary.
381
+ */
382
+ export type LookWordUnicodeNegateVariant = {
383
+ '@type': 'enum';
384
+ '@name': 'regex_syntax::hir:Look';
385
+ '@variant': 'WordUnicodeNegate';
386
+ };
387
+ /**
388
+ * Match the start of an ASCII-only word boundary. That is, this matches a
389
+ * position at either the beginning of the haystack or where the previous
390
+ * character is not a word character and the following character is a word
391
+ * character.
392
+ */
393
+ export type LookWordStartAsciiVariant = {
394
+ '@type': 'enum';
395
+ '@name': 'regex_syntax::hir:Look';
396
+ '@variant': 'WordStartAscii';
397
+ };
398
+ /**
399
+ * Match the end of an ASCII-only word boundary. That is, this matches a
400
+ * position at either the end of the haystack orwhere the previous character is
401
+ * a word character and the following character is not a word character.
402
+ */
403
+ export type LookWordEndAsciiVariant = {
404
+ '@type': 'enum';
405
+ '@name': 'regex_syntax::hir:Look';
406
+ '@variant': 'WordEndAscii';
407
+ };
408
+ /**
409
+ * Match the start of a Unicode word boundary. That is, this matches a position
410
+ * at either the beginning of the haystack or where the previous character is
411
+ * not a word character and the following character is a word character.
412
+ */
413
+ export type LookWordStartUnicodeVariant = {
414
+ '@type': 'enum';
415
+ '@name': 'regex_syntax::hir:Look';
416
+ '@variant': 'WordStartUnicode';
417
+ };
418
+ /**
419
+ * Match the end of a Unicode word boundary. That is, this matches a position at
420
+ * either the end of the haystack or where the previous character is a word
421
+ * character and the following character is not a word character.
422
+ */
423
+ export type LookWordEndUnicodeVariant = {
424
+ '@type': 'enum';
425
+ '@name': 'regex_syntax::hir:Look';
426
+ '@variant': 'WordEndUnicode';
427
+ };
428
+ /**
429
+ * Match the start half of an ASCII-only word boundary. That is, this matches a
430
+ * position at either the beginning of the haystack or where the previous
431
+ * character is not a word character.
432
+ */
433
+ export type LookWordStartHalfAsciiVariant = {
434
+ '@type': 'enum';
435
+ '@name': 'regex_syntax::hir::Look';
436
+ '@variant': 'WordStartHalfAscii';
437
+ };
438
+ /**
439
+ * Match the end half of an ASCII-only word boundary. That is, this matches a
440
+ * position at either the end of the haystack or where the following character
441
+ * is not a word character.
442
+ */
443
+ export type LookWordEndHalfAsciiVariant = {
444
+ '@type': 'enum';
445
+ '@name': 'regex_syntax::hir::Look';
446
+ '@variant': 'WordEndHalfAscii';
447
+ };
448
+ /**
449
+ * Match the start half of a Unicode word boundary. That is, this matches a
450
+ * position at either the beginning of the haystack or where the previous
451
+ * character is not a word character.
452
+ */
453
+ export type LookWordStartHalfUnicodeVariant = {
454
+ '@type': 'enum';
455
+ '@name': 'regex_syntax::hir::Look';
456
+ '@variant': 'WordStartHalfUnicode';
457
+ };
458
+ /**
459
+ * Match the end half of a Unicode word boundary. That is, this matches a
460
+ * position at either the end of the haystack or where the following character
461
+ * is not a word character.
462
+ */
463
+ export type LookWordEndHalfUnicodeVariant = {
464
+ '@type': 'enum';
465
+ '@name': 'regex_syntax::hir::Look';
466
+ '@variant': 'WordEndHalfUnicode';
467
+ };
468
+ /**
469
+ * The high-level intermediate representation of a repetition operator.
470
+ *
471
+ * A repetition operator permits the repetition of an arbitrary sub-expression
472
+ */
473
+ export type Repetition = {
474
+ '@type': 'struct';
475
+ '@name': 'regex_syntax::hir::Repetition';
476
+ /**
477
+ * The minimum range of the repetition.
478
+ *
479
+ * Note that special cases like `?`, `+` and `*` all get translated into the
480
+ * ranges `{0,1}`, `{1,}` and `{0,}`, respectively.
481
+ *
482
+ * When `min` is zero, this expression can match the empty string regardless
483
+ * of what its sub-expression is.
484
+ */
485
+ min: number;
486
+ /**
487
+ * The maximum range of the repetition.
488
+ *
489
+ * Note that when `max` is `undefined`, `min` acts as a lower bound but where
490
+ * there is no upper bound. For something like `x{5}` where the min and max
491
+ * are equivalent, `min` will be set to `5` and `max` will be set to `5`.
492
+ */
493
+ max?: number;
494
+ /**
495
+ * Whether this repetition operator is greedy or not. A greedy operator will
496
+ * match as much as it can. A non-greedy operator will match as little as it
497
+ * can.
498
+ *
499
+ * Typically, operators are greedy by default and are only non-greedy when a
500
+ * `?` suffix is used, e.g., `(expr)*` is greedy while `(expr)*?` is not.
501
+ * However, this can be inverted via the `U` “ungreedy” flag.
502
+ */
503
+ greedy: boolean;
504
+ /**
505
+ * The expression being repeated.
506
+ */
507
+ sub: Hir;
508
+ };
509
+ /**
510
+ * Represents the capture groups for a single match.
511
+ *
512
+ * Capture groups refer to parts of a regex enclosed in parentheses. They can
513
+ * be optionally named. The purpose of capture groups is to be able to
514
+ * reference different parts of a match based on the original pattern. For
515
+ * example, say you want to match the individual letters in a 5-letter word:
516
+ *
517
+ * ```text
518
+ * (?<first>\w)(\w)(?:\w)\w(?<last>\w)
519
+ * ```
520
+ *
521
+ * This regex has 4 capture groups:
522
+ *
523
+ * * The group at index `0` corresponds to the overall match. It is always
524
+ * present in every match and never has a name.
525
+ * * The group at index `1` with name `first` corresponding to the first
526
+ * letter.
527
+ * * The group at index `2` with no name corresponding to the second letter.
528
+ * * The group at index `3` with name `last` corresponding to the fifth and
529
+ * last letter.
530
+ *
531
+ * Notice that `(?:\w)` was not listed above as a capture group despite it
532
+ * being enclosed in parentheses. That's because `(?:pattern)` is a special
533
+ * syntax that permits grouping but *without* capturing. The reason for not
534
+ * treating it as a capture is that tracking and reporting capture groups
535
+ * requires additional state that may lead to slower searches. So using as few
536
+ * capture groups as possible can help performance. (Although the difference
537
+ * in performance of a couple of capture groups is likely immaterial.)
538
+ *
539
+ * # Example
540
+ *
541
+ * ```typescript
542
+ * import { RRegex } from "rregex"
543
+ *
544
+ * const re = new RRegex("(?<first>\\w)(\\w)(?:\\w)\\w(?<last>\\w)");
545
+ * const caps = re.captures("toady");
546
+ * expect(caps.get[0].value).toBe("toady");
547
+ * expect(caps.name["first"].value).toBe("t");
548
+ * expect(caps.get[2].value).toBe("o");
549
+ * expect(caps.name["last"].value).toBe("y");
550
+ * ```
551
+ */
552
+ export type Captures = {
553
+ get: Match[];
554
+ name: Record<string, Match>;
555
+ };
556
+ /**
557
+ * The high-level intermediate representation for a capturing group.
558
+ *
559
+ * A capturing group always has an index and a child expression. It may also
560
+ * have a name associated with it (e.g., `(?P<foo>\w)`), but it's not necessary.
561
+ *
562
+ * Note that there is no explicit representation of a non-capturing group in a
563
+ * `Hir`. Instead, non-capturing grouping is handled automatically by the
564
+ * recursive structure of the `Hir` itself.
565
+ */
566
+ export type Capture = {
567
+ '@type': 'struct';
568
+ '@name': 'regex_syntax::hir::Capture';
569
+ /** The capture index of the capture. */
570
+ index: number;
571
+ /** The name of the capture, if it exists. */
572
+ name?: String;
573
+ /** The expression inside the capturing group, which may be empty. */
574
+ sub: Hir;
575
+ };
576
+ /**
577
+ * Options to compile a `RRegex` or a `RRegexSet`. Every option is optional
578
+ * and only applies to the instance that receives it.
579
+ *
580
+ * # Example
581
+ *
582
+ * ```typescript
583
+ * import { RRegex } from "rregex"
584
+ *
585
+ * // Unicode classes make this pattern exceed the default 10 MiB size limit
586
+ * const re = new RRegex("\\w{200}\\s\\w{200}", { sizeLimit: 200 * 1024 * 1024 })
587
+ * ```
588
+ *
589
+ * @see https://docs.rs/regex/latest/regex/struct.RegexBuilder.html
590
+ */
591
+ export type RRegexOptions = {
592
+ /**
593
+ * The approximate size limit, in bytes, of the compiled regular expression.
594
+ * If the compiled regular expression is bigger, the constructor throws.
595
+ *
596
+ * Increase it only for patterns that need it: the compiled program uses
597
+ * WebAssembly memory, which does not shrink after the instance is freed.
598
+ *
599
+ * @default 10485760 (10 MiB)
600
+ * @see https://docs.rs/regex/latest/regex/struct.RegexBuilder.html#method.size_limit
601
+ */
602
+ sizeLimit?: number;
603
+ /**
604
+ * The approximate capacity, in bytes, of the cache of transitions used by
605
+ * the lazy DFA. A bigger cache can make searches on big patterns faster.
606
+ * If the cache is too small, the search uses a slower engine, it does not
607
+ * throw.
608
+ *
609
+ * @default 2097152 (2 MiB)
610
+ * @see https://docs.rs/regex/latest/regex/struct.RegexBuilder.html#method.dfa_size_limit
611
+ */
612
+ dfaSizeLimit?: number;
613
+ /**
614
+ * The nesting limit of the parser. If the pattern has more nested groups,
615
+ * classes or repetitions, the constructor throws.
616
+ *
617
+ * @default 250
618
+ * @see https://docs.rs/regex/latest/regex/struct.RegexBuilder.html#method.nest_limit
619
+ */
620
+ nestLimit?: number;
621
+ };
622
+ /**
623
+ * A compiled regular expression for matching Unicode strings.
624
+ *
625
+ * A `RRegex` can be used to search haystacks, split haystacks into substrings
626
+ * or replace substrings in a haystack with a different substring. All
627
+ * searching is done with an implicit `(?s:.)*?` at the beginning and end of
628
+ * an pattern. To force an expression to match the whole string (or a prefix
629
+ * or a suffix), you must use an anchor like `^` or `$` (or `\A` and `\z`).
630
+ *
631
+ * While this library will handle Unicode strings (whether in the regular
632
+ * expression or in the haystack), all positions returned are **byte
633
+ * offsets**. Every byte offset is guaranteed to be at a Unicode code point
634
+ * boundary. That is, all offsets returned by the `RRegex` API are guaranteed
635
+ * to be ranges that can slice an `Uint8Array` created with a TextEncoder.
636
+ *
637
+ * # Example: slicing over UTF strings
638
+ *
639
+ * ```typescript
640
+ * import { RRegex } from "rregex"
641
+ *
642
+ * const re = new RRegex("ä")
643
+ * const m = re.find("äöü") // { start: 0, end: 2 }
644
+ *
645
+ * const buff = new TextEncoder().encode("äöü")
646
+ * const slice = buff.slice(m.start, m.end)
647
+ * expect(new TextDecoder().decode(slice)).toBe("ä")
648
+ * ```
649
+ *
650
+ * # Example: find the offsets of a US phone number:
651
+ *
652
+ * ```typescript
653
+ * import { RRegex } from "rregex"
654
+ *
655
+ * const re = new RRegex("[0-9]{3}-[0-9]{3}-[0-9]{4}");
656
+ * const m = re.find("phone: 111-222-3333");
657
+ * expect(m.start).toBe(7);
658
+ * expect(m.end).toBe(19);
659
+ * ```
660
+ *
661
+ * @see https://docs.rs/regex/latest/regex/
662
+ */
663
+ export declare class RRegex {
664
+ free(): void;
665
+ /**
666
+ * Returns the same as is_match, but starts the search at the given offset.
667
+ * The significance of the starting point is that it takes the surrounding
668
+ * context into consideration. For example, the `\A` anchor can only match
669
+ * when `start == 0`.
670
+ *
671
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.is_match_at
672
+ * @param {string} text - The string against which to match the regular expression
673
+ * @param {number} start - Zero-based index at which to start matching
674
+ * @return {boolean}
675
+ */
676
+ isMatchAt(text: string, start: number): boolean;
677
+ /**
678
+ * Replaces all non-overlapping matches in `text` with the replacement
679
+ * provided. This is the same as calling `replacen` with `limit` set to
680
+ * `0`.
681
+ *
682
+ * See the documentation for `replace` for details on how to access
683
+ * capturing group matches in the replacement string.
684
+ *
685
+ * See the documentation for `replace` for details on how to access capturing group matches in the replacement string.
686
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.replace_all
687
+ * @param {string} text - The string against which to match the regular expression
688
+ * @param {string} rep - It's a string, it will replace the substring matched by `pattern`.
689
+ * @returns {string}
690
+ */
691
+ replaceAll(text: string, rep: string): string;
692
+ /**
693
+ * Returns a list with all the non-overlapping capture groups matched
694
+ * in `text`. This is operationally the same as `findAll`, except it
695
+ * returns information about capturing group matches.
696
+ *
697
+ * # Example
698
+ *
699
+ * We can use this to find all movie titles and their release years in
700
+ * some text, where the movie is formatted like "'Title' (xxxx)":
701
+ *
702
+ * ```typescript
703
+ * import { RRegex } from "rregex"
704
+ *
705
+ * const re = new RRegex("'(?P<title>[^']+)'\\s+\\((?P<year>\\d{4})\\)")
706
+ * const text = "'Citizen Kane' (1941), 'The Wizard of Oz' (1939), 'M' (1931)."
707
+ * for caps of re.captures_iter(text) {
708
+ * console.log(
709
+ * "Movie:", caps.name["title"].value, ","
710
+ * "Released:", caps.name["year"].value
711
+ * );
712
+ * }
713
+ * // Output:
714
+ * // Movie: Citizen Kane, Released: 1941
715
+ * // Movie: The Wizard of Oz, Released: 1939
716
+ * // Movie: M, Released: 1931
717
+ * ```
718
+ *
719
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.captures_iter
720
+ * @param {string} text - The string against which to match the regular expression
721
+ * @returns {Captures[]}
722
+ */
723
+ capturesAll(text: string): Captures[];
724
+ /**
725
+ * Returns the number of captures.
726
+ *
727
+ * This includes all named and unnamed groups, including the implicit
728
+ * unnamed group that is always present and corresponds to the entire match.
729
+ *
730
+ * Since the implicit unnamed group is always included in this length, the
731
+ * length returned is guaranteed to be greater than zero.
732
+ *
733
+ * ## Example
734
+ *
735
+ * ```typescript
736
+ * import { RRegex } from "rregex"
737
+ *
738
+ * const re1 = new RRegex("(?P<y>\\d{4})-(?P<m>\\d{2})-(?P<d>\\d{2})")
739
+ * expect(re1.capturesLength()).toEqual(4)
740
+ *
741
+ * const re2 = new RRegex("foo")
742
+ * expect(re2.capturesLength()).toEqual(1)
743
+ *
744
+ * const re3 = new RRegex("(foo)")
745
+ * expect(re3.capturesLength()).toEqual(2)
746
+ *
747
+ * const re4 = new RRegex("(?<a>.(?<b>.))(.)(?:.)(?<c>.)")
748
+ * expect(re4.capturesLength()).toEqual(5)
749
+ *
750
+ * const re5 = new RRegex("[a&&b]")
751
+ * expect(re5.capturesLength()).toEqual(1)
752
+ * ```
753
+ *
754
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.captures_len
755
+ */
756
+ capturesLength(): number;
757
+ /**
758
+ * Returns a list of the capture names in this regex.
759
+ *
760
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.capture_names
761
+ */
762
+ captureNames(): (string | null)[];
763
+ /**
764
+ * Returns the end location of a match in the text given.
765
+ *
766
+ * This method may have the same performance characteristics as
767
+ * `isMatch`, except it provides an end location for a match. In
768
+ * particular, the location returned *may be shorter* than the proper end
769
+ * of the leftmost-first match that you would find via `Regex.find`.
770
+ *
771
+ * Note that it is not guaranteed that this routine finds the shortest or
772
+ * "earliest" possible match. Instead, the main idea of this API is that
773
+ * it returns the offset at the point at which the internal regex engine
774
+ * has determined that a match has occurred. This may vary depending on
775
+ * which internal regex engine is used, and thus, the offset itself may
776
+ * change.
777
+ *
778
+ * # Example
779
+ *
780
+ * Typically, `a+` would match the entire first sequence of `a` in some
781
+ * text, but `shortest_match` can give up as soon as it sees the first
782
+ * `a`.
783
+ *
784
+ * ```typescript
785
+ * import { RRegex } from "rregex"
786
+ *
787
+ * const text = "aaaaa"
788
+ * const = new RRegex("a+").shortest_match(text)
789
+ * expect(pos).toBe(1)
790
+ * ```
791
+ *
792
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.shortest_match
793
+ * @param {string} text - The string against which to match the regular expression
794
+ * @returns {number|undefined}
795
+ */
796
+ shortestMatch(text: string): number | undefined;
797
+ /**
798
+ * Returns the same as `shortest_match`, but starts the search at the
799
+ * given offset.
800
+ *
801
+ * The significance of the starting point is that it takes the surrounding
802
+ * context into consideration. For example, the `\A` anchor can only match
803
+ * when `start == 0`.
804
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.shortest_match_at
805
+ * @param {string} text - The string against which to match the regular expression
806
+ * @param {number} start - Zero-based index at which to start matching
807
+ * @returns {number|undefined}
808
+ */
809
+ shortestMatchAt(text: string, start: number): number | undefined;
810
+ /**
811
+ * Compiles a regular expression. Once compiled, it can be used repeatedly
812
+ * to search, split or replace text in a string.
813
+ *
814
+ * If an invalid expression is given, then an error is returned.
815
+ * Options only apply to this instance, see `RRegexOptions`.
816
+ */
817
+ constructor(re: string, options?: RRegexOptions | null);
818
+ /**
819
+ * Returns the start and end byte range of the leftmost-first match in
820
+ * `text`. If no match exists, then `undefined` is returned.
821
+ *
822
+ * Note that this should only be used if you want to discover the position
823
+ * of the match. Testing the existence of a match is faster if you use
824
+ * `isMatch`.
825
+ *
826
+ * # Example
827
+ *
828
+ * Find the start and end location of the first word with exactly 13
829
+ * Unicode word characters:
830
+ *
831
+ * ```typescript
832
+ * import { RRegex } from "rregex"
833
+ *
834
+ * const text = "I categorically deny having triskaidekaphobia."
835
+ * const m = new RRegex("\\b\\w{13}\\b").find(text)
836
+ * expect(m.start).toBe(2)
837
+ * expect(m.end).toBe(15)
838
+ * ```
839
+ *
840
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.find
841
+ * @param {string} text - The string against which to match the regular expression
842
+ * @return {Match}
843
+ */
844
+ find(text: string): Match | undefined;
845
+ /**
846
+ * Returns an iterator of substrings of `text` delimited by a match of the
847
+ * regular expression. Namely, each element of the iterator corresponds to
848
+ * text that *isn't* matched by the regular expression.
849
+ *
850
+ * This method will *not* copy the text given.
851
+ *
852
+ * # Example
853
+ *
854
+ * To split a string delimited by arbitrary amounts of spaces or tabs:
855
+ *
856
+ * ```typescript
857
+ * import { RRegex } from "rregex"
858
+ *
859
+ * const re = new RRegex(r"[ \\t]+")
860
+ * const fields = re.split("a b \t c\td e")
861
+ * expect(fields).toEqual(["a", "b", "c", "d", "e"])
862
+ * ```
863
+ *
864
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.split
865
+ * @param {string} text - The string against which to match the regular expression
866
+ * @returns {string[]}
867
+ */
868
+ split(text: string): string[];
869
+ /**
870
+ * Returns an iterator of at most `limit` substrings of `text` delimited
871
+ * by a match of the regular expression. (A `limit` of `0` will return no
872
+ * substrings.) Namely, each element of the iterator corresponds to text
873
+ * that *isn't* matched by the regular expression. The remainder of the
874
+ * string that is not split will be the last element in the iterator.
875
+ *
876
+ * This method will *not* copy the text given.
877
+ *
878
+ * # Example
879
+ *
880
+ * Get the first two words in some text:
881
+ *
882
+ * ```typescript
883
+ * import { RRegex } from "rregex"
884
+ *
885
+ * const re = new RRegex(r"\\W+")
886
+ * const fields = re.splitn("Hey! How are you?", 3)
887
+ * expect(fields).toEqual(["Hey", "How", "are you?"])
888
+ * ```
889
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.splitn
890
+ * @param {string} text - The string against which to match the regular expression
891
+ * @param {number} limit - Max number result elements
892
+ * @returns {string[]}
893
+ */
894
+ splitn(text: string, limit: number): string[];
895
+ /**
896
+ * Returns the regular expression into a high level intermediate
897
+ * representation.
898
+ */
899
+ syntax(): Hir;
900
+ /**
901
+ * Returns the same as find, but starts the search at the given
902
+ * offset.
903
+ *
904
+ * The significance of the starting point is that it takes the surrounding
905
+ * context into consideration. For example, the `\A` anchor can only
906
+ * match when `start == 0`.
907
+ *
908
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.find_at
909
+ * @param {string} text - The string against which to match the regular expression
910
+ * @param {number} start - Zero-based index at which to start matching
911
+ * @returns {Match}
912
+ */
913
+ findAt(text: string, start: number): Match | undefined;
914
+ /**
915
+ * Replaces the leftmost-first match with the replacement provided.
916
+ * The replacement can be a regular string (where `$N` and `$name` are
917
+ * expanded to match capture groups) or a function that takes the matches'
918
+ * `Captures` and returns the replaced string.
919
+ *
920
+ * If no match is found, then a copy of the string is returned unchanged.
921
+ *
922
+ * # Replacement string syntax
923
+ *
924
+ * All instances of `$name` in the replacement text is replaced with the
925
+ * corresponding capture group `name`.
926
+ *
927
+ * `name` may be an integer corresponding to the index of the
928
+ * capture group (counted by order of opening parenthesis where `0` is the
929
+ * entire match) or it can be a name (consisting of letters, digits or
930
+ * underscores) corresponding to a named capture group.
931
+ *
932
+ * If `name` isn't a valid capture group (whether the name doesn't exist
933
+ * or isn't a valid index), then it is replaced with the empty string.
934
+ *
935
+ * The longest possible name is used. e.g., `$1a` looks up the capture
936
+ * group named `1a` and not the capture group at index `1`. To exert more
937
+ * precise control over the name, use braces, e.g., `${1}a`.
938
+ *
939
+ * To write a literal `$` use `$$`.
940
+ *
941
+ * # Examples
942
+ *
943
+ * Note that this function is polymorphic with respect to the replacement.
944
+ * In typical usage, this can just be a normal string:
945
+ *
946
+ * ```typescript
947
+ * import { RRegex } from "rregex"
948
+ *
949
+ * const re = new RRegex("[^01]+")
950
+ * expect(re.replace("1078910", "").toBe("1010")
951
+ * ```
952
+ *
953
+ * Here's the example using this expansion technique with named capture
954
+ * groups:
955
+ *
956
+ * ```typescript
957
+ * import { RRegex } from "rregex"
958
+ *
959
+ * const re = new RRegex("(?P<last>[^,\\s]+),\\s+(?P<first>\\S+)")
960
+ * const result = re.replace("Springsteen, Bruce", "$first $last")
961
+ * expect(result).toBe("Bruce Springsteen")
962
+ * ```
963
+ *
964
+ * Note that using `$2` instead of `$first` or `$1` instead of `$last`
965
+ * would produce the same result. To write a literal `$` use `$$`.
966
+ *
967
+ * Sometimes the replacement string requires use of curly braces to
968
+ * delineate a capture group replacement and surrounding literal text.
969
+ * For example, if we wanted to join two words together with an
970
+ * underscore:
971
+ *
972
+ * ```typescript
973
+ * import { RRegex } from "rregex"
974
+ *
975
+ * const re = new RRegex("(?P<first>\\w+)\\s+(?P<second>\\w+)")
976
+ * const result = re.replace("deep fried", "${first}_$second")
977
+ * expect(result).toBe("deep_fried")
978
+ * ```
979
+ *
980
+ * Without the curly braces, the capture group name `first_` would be
981
+ * used, and since it doesn't exist, it would be replaced with the empty
982
+ * string.
983
+ *
984
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.replace
985
+ * @param {string} text - The string against which to match the regular expression
986
+ * @param {string} rep - It's a string, it will replace the substring matched by `pattern`.
987
+ * @returns {string}
988
+ */
989
+ replace(text: string, rep: string): string;
990
+ /**
991
+ * Returns the capture groups corresponding to the leftmost-first
992
+ * match in `text`. Capture group `0` always corresponds to the entire
993
+ * match. If no match is found, then `undefined` is returned.
994
+ *
995
+ * You should only use `captures` if you need access to the location of
996
+ * capturing group matches. Otherwise, `find` is faster for discovering
997
+ * the location of the overall match.
998
+ *
999
+ * # Examples
1000
+ *
1001
+ * Say you have some text with movie names and their release years,
1002
+ * like "'Citizen Kane' (1941)". It'd be nice if we could search for text
1003
+ * looking like that, while also extracting the movie name and its release
1004
+ * year separately.
1005
+ *
1006
+ * ```typescript
1007
+ * import { RRegex } from "rregex"
1008
+ *
1009
+ * const re = new RRegex("'([^']+)'\\s+\\((\\d{4})\)")
1010
+ * const text = "Not my favorite movie: 'Citizen Kane' (1941)."
1011
+ * const caps = re.captures(text)
1012
+ * expect(caps.get[1].value).toBe("Citizen Kane")
1013
+ * expect(caps.get[2].value).toBe("1941")
1014
+ * expect(caps.get[0].value).toBe("'Citizen Kane' (1941)")
1015
+ * ```
1016
+ *
1017
+ * Note that the full match is at capture group `0`. Each subsequent
1018
+ * capture group is indexed by the order of its opening `(`.
1019
+ *
1020
+ * We can make this example a bit clearer by using *named* capture groups:
1021
+ *
1022
+ * ```typescript
1023
+ * import { RRegex } from "rregex"
1024
+ *
1025
+ * const re = new RRegex("'(?P<title>[^']+)'\\s+\\((?P<year>\\d{4})\)")
1026
+ * const text = "Not my favorite movie: 'Citizen Kane' (1941)."
1027
+ * const caps = re.captures(text)
1028
+ * expect(caps.name["title"].value).toBe("Citizen Kane")
1029
+ * expect(caps.name["year"].value).toBe("1941")
1030
+ * expect(caps.get[0].value).toBe("'Citizen Kane' (1941)")
1031
+ * ```
1032
+ *
1033
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.captures
1034
+ * @param {string} text - The string against which to match the regular expression
1035
+ * @returns {Captures|undefined}
1036
+ */
1037
+ captures(text: string): Captures | undefined;
1038
+ /**
1039
+ * Returns an array for each successive non-overlapping match in `text``,
1040
+ * returning the start and end byte indices with respect to `text`.
1041
+ *
1042
+ * # Example
1043
+ *
1044
+ * Find the start and end location of every word with exactly 13 Unicode
1045
+ * word characters:
1046
+ *
1047
+ * ```typescript
1048
+ * import { RRegex } from "rregex"
1049
+ *
1050
+ * const text = "Retroactively relinquishing remunerations is reprehensible."
1051
+ * const matches = new RRegex("\\b\\w{13}\\b").findAll(text)
1052
+ * ```
1053
+ *
1054
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.find_iter
1055
+ * @param {string} text - The string against which to match the regular expression
1056
+ * @returns {Match}
1057
+ */
1058
+ findAll(text: string): Match[];
1059
+ /**
1060
+ * Returns true if and only if there is a match for the regex in the
1061
+ * string given.
1062
+ *
1063
+ * It is recommended to use this method if all you need to do is test
1064
+ * a match, since the underlying matching engine may be able to do less
1065
+ * work.
1066
+ *
1067
+ * # Example
1068
+ *
1069
+ * Test if some text contains at least one word with exactly 13
1070
+ * Unicode word characters:
1071
+ *
1072
+ * ```typescript
1073
+ * import { RRegex } from "rregex"
1074
+ *
1075
+ * const text = "I categorically deny having triskaidekaphobia."
1076
+ * expect(new RRegex("\\b\\w{13}\\b").is_match(text)).toBe(true)
1077
+ * ```
1078
+ *
1079
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.is_match
1080
+ * @param {string} text - The string against which to match the regular expression
1081
+ * @return {boolean}
1082
+ */
1083
+ isMatch(text: string): boolean;
1084
+ /**
1085
+ * Replaces at most `limit` non-overlapping matches in `text` with the
1086
+ * replacement provided. If `limit` is 0, then all non-overlapping matches
1087
+ * are replaced.
1088
+ *
1089
+ * See the documentation for `replace` for details on how to access
1090
+ * capturing group matches in the replacement string.
1091
+ *
1092
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.replacen
1093
+ * @param {string} text - The string against which to match the regular expression
1094
+ * @param {number} limit - Max number of replacement
1095
+ * @param {string} rep - It's a string, it will replace the substring matched by `pattern`.
1096
+ * @returns {string}
1097
+ */
1098
+ replacen(text: string, limit: number, rep: string): string;
1099
+ /**
1100
+ * Returns a string representing the regular expression
1101
+ */
1102
+ toString(): string;
1103
+ }
1104
+ /**
1105
+ * Match multiple (possibly overlapping) regular expressions in a single scan.
1106
+ * A regex set corresponds to the union of two or more regular expressions.
1107
+ *
1108
+ * That is, a regex set will match text where at least one of its constituent
1109
+ * regular expressions matches. A regex set as its formulated here provides a
1110
+ * touch more power: it will also report which regular expressions in the set match.
1111
+ * Indeed, this is the key difference between regex sets and a single `Regex`
1112
+ * with many alternates, since only one alternate can match at a time.
1113
+ *
1114
+ * @see https://docs.rs/regex/latest/regex/struct.RegexSet.html#method.empty
1115
+ */
1116
+ export declare class RRegexSet {
1117
+ free(): void;
1118
+ /**
1119
+ * Create a new regex set with the given regular expressions.
1120
+ *
1121
+ * This takes an array of strings, if any item in the list is not a valid regular
1122
+ * expression, then an error is returned. Options only apply to this
1123
+ * instance, see `RRegexOptions`.
1124
+ *
1125
+ * # Example
1126
+ *
1127
+ * Create a new regex set from an iterator of strings:
1128
+ *
1129
+ * ```typescript
1130
+ * import { RegexSet } from "rregex"
1131
+ *
1132
+ * const set = new RegexSet(["\\w+", "\\d+"])
1133
+ * expect(set.is_match("foo")).toBe(true)
1134
+ * ```
1135
+ */
1136
+ constructor(list: string[], options?: RRegexOptions | null);
1137
+ /**
1138
+ * Returns the set of regular expressions that match in the given text.
1139
+ *
1140
+ * The set returned contains the index of each regular expression that
1141
+ * matches in the given text. The index is in correspondence with the
1142
+ * order of regular expressions given to `RegexSet`'s constructor.
1143
+ *
1144
+ * The set can also be used to iterate over the matched indices.
1145
+ *
1146
+ * Note that as with searches using `Regex`, the expression is unanchored
1147
+ * by default. That is, if the regex does not start with `^` or `\A`, or
1148
+ * end with `$` or `\z`, then it is permitted to match anywhere in the
1149
+ * text.
1150
+ *
1151
+ * # Example
1152
+ *
1153
+ * Tests which regular expressions match the given text:
1154
+ *
1155
+ * ```typescript
1156
+ * import { RegexSet } from "rregex"
1157
+ *
1158
+ * const set = new RegexSet([
1159
+ * "\\w+",
1160
+ * "\\d+",
1161
+ * "\\pL+",
1162
+ * "foo",
1163
+ * "bar",
1164
+ * "barfoo",
1165
+ * "foobar",
1166
+ * ])
1167
+ * const matches = set.matches("foobar")
1168
+ * expect(matches).toBe([0, 2, 3, 4, 6])
1169
+ * ```
1170
+ *
1171
+ * @see https://docs.rs/regex/latest/regex/struct.RegexSet.html#method.matches
1172
+ * @param {string} text - The string against which to match the regular expression
1173
+ * @return {number[]}
1174
+ */
1175
+ matches(text: string): number[];
1176
+ /**
1177
+ * Returns true if and only if one of the regexes in this set matches
1178
+ * the text given.
1179
+ *
1180
+ * This method should be preferred if you only need to test whether any
1181
+ * of the regexes in the set should match, but don't care about *which*
1182
+ * regexes matched. This is because the underlying matching engine will
1183
+ * quit immediately after seeing the first match instead of continuing to
1184
+ * find all matches.
1185
+ *
1186
+ * Note that as with searches using `Regex`, the expression is unanchored
1187
+ * by default. That is, if the regex does not start with `^` or `\A`, or
1188
+ * end with `$` or `\z`, then it is permitted to match anywhere in the
1189
+ * text.
1190
+ *
1191
+ * # Example
1192
+ *
1193
+ * Tests whether a set matches some text:
1194
+ *
1195
+ * ```typescript
1196
+ * import { RegexSet } from "rregex"
1197
+ *
1198
+ * const set = new RegexSet(["\\w+", "\\d+"])
1199
+ * expect(set.is_match("foo")).toBe(true)
1200
+ * expect(!set.is_match("☃")).toBe(false)
1201
+ * ```
1202
+ *
1203
+ * @see https://docs.rs/regex/latest/regex/struct.RegexSet.html#method.is_match
1204
+ * @param {string} text - The string against which to match the regular expression
1205
+ * @return {boolean}
1206
+ */
1207
+ isMatch(text: string): boolean;
1208
+ }
1209
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
1210
+ export interface InitOutput {
1211
+ readonly memory: WebAssembly.Memory;
1212
+ readonly __wbg_rregex_free: (a: number, b: number) => void;
1213
+ readonly rregex_captureNames: (a: number) => [number, number];
1214
+ readonly rregex_captures: (a: number, b: number, c: number) => [number, number, number];
1215
+ readonly rregex_capturesAll: (a: number, b: number, c: number) => [number, number, number];
1216
+ readonly rregex_capturesLength: (a: number) => number;
1217
+ readonly rregex_find: (a: number, b: number, c: number) => [number, number, number];
1218
+ readonly rregex_findAll: (a: number, b: number, c: number) => [number, number, number];
1219
+ readonly rregex_findAt: (a: number, b: number, c: number, d: number) => [number, number, number];
1220
+ readonly rregex_isMatch: (a: number, b: number, c: number) => number;
1221
+ readonly rregex_isMatchAt: (a: number, b: number, c: number, d: number) => number;
1222
+ readonly rregex_new: (a: number, b: number, c: number) => [number, number, number];
1223
+ readonly rregex_replace: (a: number, b: number, c: number, d: number, e: number) => [number, number];
1224
+ readonly rregex_replaceAll: (a: number, b: number, c: number, d: number, e: number) => [number, number];
1225
+ readonly rregex_replacen: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
1226
+ readonly rregex_shortestMatch: (a: number, b: number, c: number) => number;
1227
+ readonly rregex_shortestMatchAt: (a: number, b: number, c: number, d: number) => number;
1228
+ readonly rregex_split: (a: number, b: number, c: number) => [number, number];
1229
+ readonly rregex_splitn: (a: number, b: number, c: number, d: number) => [number, number];
1230
+ readonly rregex_syntax: (a: number) => [number, number, number];
1231
+ readonly rregex_toString: (a: number) => [number, number];
1232
+ readonly __wbg_rregexset_free: (a: number, b: number) => void;
1233
+ readonly rregexset_isMatch: (a: number, b: number, c: number) => number;
1234
+ readonly rregexset_matches: (a: number, b: number, c: number) => [number, number];
1235
+ readonly rregexset_new: (a: any, b: number) => [number, number, number];
1236
+ readonly escape: (a: number, b: number) => [number, number];
1237
+ readonly __wbindgen_exn_store: (a: number) => void;
1238
+ readonly __externref_table_alloc: () => number;
1239
+ readonly __wbindgen_export_2: WebAssembly.Table;
1240
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
1241
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
1242
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
1243
+ readonly __externref_table_dealloc: (a: number) => void;
1244
+ readonly __externref_drop_slice: (a: number, b: number) => void;
1245
+ readonly __wbindgen_start: () => void;
1246
+ }
1247
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
1248
+ /** Build metadata */
1249
+ export declare const metadata: {
1250
+ readonly name: "rregex";
1251
+ readonly description: "Rust Regex binding for Javascript";
1252
+ readonly authors: readonly ["Fede Ramirez <i@2fd.me>"];
1253
+ readonly homepage: "http://rregex.dev";
1254
+ readonly repository: "https://github.com/2fd/rregex";
1255
+ readonly regex: "1.13.1";
1256
+ readonly "regex-syntax": "0.8.11";
1257
+ };
1258
+ export interface InitOptions {
1259
+ /** Bytes, a compiled `WebAssembly.Module`, or a `Response`, URL or path to fetch. */
1260
+ module_or_path: InitInput | Promise<InitInput>;
1261
+ }
1262
+ export interface InitSyncOptions {
1263
+ /** Bytes or a compiled `WebAssembly.Module`. */
1264
+ module: SyncInitInput;
1265
+ }
1266
+ /**
1267
+ * The raw exports of the WebAssembly instance (`memory`, allocator, bindings),
1268
+ * set by {@link init} and {@link initSync}. For tests and debugging only: it
1269
+ * is not part of the public API and can change in any release.
1270
+ *
1271
+ * @internal
1272
+ */
1273
+ export declare let __wasm: InitOutput | undefined;
1274
+ /** Returns `true` after the WebAssembly module has been instantiated. */
1275
+ export declare function isInitialized(): boolean;
1276
+ /**
1277
+ * Instantiates the WebAssembly module synchronously. Calls after the first
1278
+ * successful call have no effect.
1279
+ *
1280
+ * @param options - The module, or (deprecated) the module passed directly.
1281
+ */
1282
+ export declare function initSync(options: InitSyncOptions | SyncInitInput): void;
1283
+ /**
1284
+ * Instantiates the WebAssembly module asynchronously. Calls after the first
1285
+ * successful call have no effect.
1286
+ */
1287
+ export declare function init(options: InitOptions): Promise<void>;