rregex 1.10.4 → 1.10.6

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