rregex 1.8.1 → 1.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/esm.d.ts ADDED
@@ -0,0 +1,1001 @@
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 function escape(text: string): string;
10
+ /**
11
+ * Represents a single match of a regex in a haystack.
12
+ */
13
+ export type Match = {
14
+ start: number
15
+ end: number
16
+ value: string
17
+ }
18
+
19
+ /**
20
+ * A high-level intermediate representation (HIR) for a regular expression.
21
+ */
22
+ export type Hir = {
23
+ '@type': 'struct'
24
+ '@name': 'regex_syntax::hir::Hir'
25
+ kind: HirKind
26
+ }
27
+
28
+ /**
29
+ * The underlying kind of an arbitrary `Hir` expression.
30
+ *
31
+ * An `HirKind` is principally useful for doing case analysis on the type of a
32
+ * regular expression. If you're looking to build new `Hir` values, then you must
33
+ * use the smart constructors defined on `Hir`, like `Hir::repetition`, to build
34
+ * new `Hir` values. The API intentionally does not expose any way of building an
35
+ * `Hir` directly from an `HirKind`.
36
+ */
37
+ export type HirKind =
38
+ | HirKindEmptyVariant
39
+ | HirKindLiteralVariant
40
+ | HirKindClassVariant
41
+ | HirKindLookVariant
42
+ | HirKindRepetitionVariant
43
+ | HirKindCaptureVariant
44
+ | HirKindConcatVariant
45
+ | HirKindAlternationVariant
46
+
47
+ /**
48
+ * The empty regular expression, which matches everything, including the empty string.
49
+ */
50
+ export type HirKindEmptyVariant = {
51
+ '@type': 'enum'
52
+ '@name': 'regex_syntax::hir::HirKind'
53
+ '@variant': 'Empty'
54
+ }
55
+
56
+ /**
57
+ * A literal string that matches exactly these bytes.
58
+ */
59
+ export type HirKindLiteralVariant = {
60
+ '@type': 'enum'
61
+ '@name': 'regex_syntax::hir::HirKind'
62
+ '@variant': 'Literal'
63
+ '@values': [Literal]
64
+ }
65
+
66
+ /**
67
+ * A single character class that matches any of the characters in the class.
68
+ * A class can either consist of Unicode scalar values as characters, or it can
69
+ * use bytes.
70
+ *
71
+ * A class may be empty. In which case, it matches nothing.
72
+ */
73
+ export type HirKindClassVariant = {
74
+ '@type': 'enum'
75
+ '@name': 'regex_syntax::hir::HirKind'
76
+ '@variant': 'Class'
77
+ '@values': [Class]
78
+ }
79
+
80
+ /**
81
+ * A look-around assertion. A look-around match always has zero length.
82
+ */
83
+ export type HirKindLookVariant = {
84
+ '@type': 'enum'
85
+ '@name': 'regex_syntax::hir::HirKind'
86
+ '@variant': 'Look'
87
+ '@values': [Look]
88
+ }
89
+
90
+ /**
91
+ * A repetition operation applied to a sub-expression.
92
+ */
93
+ export type HirKindRepetitionVariant = {
94
+ '@type': 'enum'
95
+ '@name': 'regex_syntax::hir::HirKind'
96
+ '@variant': 'Repetition'
97
+ '@values': [Repetition]
98
+ }
99
+
100
+ /**
101
+ * A capturing group, which contains a sub-expression.
102
+ */
103
+ export type HirKindCaptureVariant = {
104
+ '@type': 'enum'
105
+ '@name': 'regex_syntax::hir::HirKind'
106
+ '@variant': 'Capture'
107
+ '@values': [Capture]
108
+ }
109
+
110
+ /**
111
+ * A concatenation of expressions.
112
+ *
113
+ * A concatenation matches only if each of its sub-expressions match one after
114
+ * the other.
115
+ *
116
+ * Concatenations are guaranteed by `Hir`'s smart constructors to always have at
117
+ * least two sub-expressions.
118
+ */
119
+ export type HirKindConcatVariant = {
120
+ '@type': 'enum'
121
+ '@name': 'regex_syntax::hir::HirKind'
122
+ '@variant': 'Concat'
123
+ '@values': [Hir[]]
124
+ }
125
+
126
+ /**
127
+ * An alternation of expressions.
128
+ *
129
+ * An alternation matches only if at least one of its sub-expressions match.
130
+ * If multiple sub-expressions match, then the leftmost is preferred.
131
+ *
132
+ * Alternations are guaranteed by `Hir`'s smart constructors to always have at
133
+ * least two sub-expressions.
134
+ */
135
+ export type HirKindAlternationVariant = {
136
+ '@type': 'enum'
137
+ '@name': 'regex_syntax::hir::HirKind'
138
+ '@variant': 'Alternation'
139
+ '@values': [Hir[]]
140
+ }
141
+
142
+ /**
143
+ * The high-level intermediate representation of a literal.
144
+ *
145
+ * A literal corresponds to 0 or more bytes that should be matched literally.
146
+ * The smart constructors defined on `Hir` will automatically concatenate adjacent
147
+ * literals into one literal, and will even automatically replace empty literals
148
+ * with `HirKind::Empty`.
149
+ */
150
+ export type Literal = {
151
+ '@type': 'struct'
152
+ '@name': 'regex_syntax::hir::Literal'
153
+ '@values': [Uint8Array]
154
+ }
155
+
156
+ /**
157
+ * The high-level intermediate representation of a character class.
158
+ *
159
+ * A character class corresponds to a set of characters. A character is either
160
+ * defined by a Unicode scalar value or a byte. Unicode characters are used by
161
+ * default, while bytes are used when Unicode mode (via the `u` flag) is disabled.
162
+ *
163
+ * A character class, regardless of its character type, is represented by a
164
+ * sequence of non-overlapping non-adjacent ranges of characters.
165
+ *
166
+ * Note that `Bytes` variant may be produced even when it exclusively matches
167
+ * valid UTF-8. This is because a `Bytes` variant represents an intention by the
168
+ * author of the regular expression to disable Unicode mode, which in turn
169
+ * impacts the semantics of case insensitive matching. For example, `(?i)k` and
170
+ * `(?i-u)k` will not match the same set of strings.
171
+ */
172
+ export type Class =
173
+ | ClassUnicodeVariant
174
+ | ClassByteVariant
175
+
176
+ /**
177
+ * A set of characters represented by Unicode scalar values.
178
+ */
179
+ export type ClassUnicodeVariant = {
180
+ '@type': 'enum'
181
+ '@name': 'regex_syntax::hir::Class'
182
+ '@variant': 'Unicode'
183
+ '@values': [ClassUnicode]
184
+ }
185
+
186
+ /**
187
+ * A set of characters represented by arbitrary bytes (one byte per character).
188
+ */
189
+ export type ClassByteVariant = {
190
+ '@type': 'enum'
191
+ '@name': 'regex_syntax::hir::Class'
192
+ '@variant': 'Bytes'
193
+ '@values': [ClassBytes]
194
+ }
195
+
196
+ /**
197
+ * A set of characters represented by Unicode scalar values.
198
+ */
199
+ export type ClassUnicode = {
200
+ '@type': 'struct'
201
+ '@name': 'regex_syntax::hir::ClassUnicode'
202
+
203
+ /** The underlying ranges as a slice. */
204
+ ranges: ClassUnicodeRange[]
205
+ }
206
+
207
+ /**
208
+ * A single range of characters represented by Unicode scalar values.
209
+ *
210
+ * The range is closed. That is, the start and end of the range are included in
211
+ * the range.
212
+ */
213
+ export type ClassUnicodeRange = {
214
+ '@type': 'struct'
215
+ '@name': 'regex_syntax::hir::ClassUnicodeRange'
216
+
217
+ /**
218
+ * Return the start of this range.
219
+ *
220
+ * The start of a range is always less than or equal to the end of the range.
221
+ */
222
+ start: string
223
+
224
+ /**
225
+ * Return the end of this range.
226
+ *
227
+ * The end of a range is always greater than or equal to the start of the range.
228
+ */
229
+ end: string
230
+
231
+ /**
232
+ * The number of codepoints in this range.
233
+ */
234
+ len: number
235
+ }
236
+
237
+ /**
238
+ * A set of characters represented by arbitrary bytes (where one byte corresponds
239
+ * to one character).
240
+ */
241
+ export type ClassBytes = {
242
+ '@type': 'struct'
243
+ '@name': 'regex_syntax::hir::ClassBytes'
244
+
245
+ /** The underlying ranges as a slice. */
246
+ ranges: ClassBytesRange[]
247
+ }
248
+
249
+ /**
250
+ * A single range of characters represented by arbitrary bytes.
251
+ *
252
+ * The range is closed. That is, the start and end of the range are included in
253
+ * the range.
254
+ */
255
+ export type ClassBytesRange = {
256
+ '@type': 'struct'
257
+ '@name': 'regex_syntax::hir::ClassBytesRange'
258
+
259
+ /**
260
+ * The start of this range.
261
+ *
262
+ * The start of a range is always less than or equal to the end of the range.
263
+ */
264
+ start: number
265
+
266
+ /**
267
+ * The end of this range.
268
+ *
269
+ * The end of a range is always greater than or equal to the start of the range.
270
+ */
271
+ end: number
272
+
273
+ /**
274
+ * The number of bytes in this range.
275
+ */
276
+ len: number
277
+ }
278
+
279
+ /**
280
+ * The high-level intermediate representation for a look-around assertion.
281
+ *
282
+ * An assertion match is always zero-length. Also called an “empty match.”
283
+ */
284
+ export type Look =
285
+ | LookStartVariant
286
+ | LookEndVariant
287
+ | LookStartLFVariant
288
+ | LookEndLFVariant
289
+ | LookStartCRLFVariant
290
+ | LookEndCRLFVariant
291
+ | LookWordAsciiVariant
292
+ | LookWordAsciiNegateVariant
293
+ | LookWordUnicodeVariant
294
+ | LookWordUnicodeNegateVariant
295
+
296
+ /**
297
+ * Match the beginning of text. Specifically, this matches at the starting
298
+ * position of the input.
299
+ */
300
+ export type LookStartVariant = {
301
+ '@type': 'enum'
302
+ '@name': 'regex_syntax::hir:Look'
303
+ '@variant': 'Start'
304
+ }
305
+
306
+ /**
307
+ * Match the end of text. Specifically, this matches at the ending position of
308
+ * the input.
309
+ */
310
+ export type LookEndVariant = {
311
+ '@type': 'enum'
312
+ '@name': 'regex_syntax::hir:Look'
313
+ '@variant': 'End'
314
+ }
315
+
316
+ /**
317
+ * Match the beginning of a line or the beginning of text. Specifically, this
318
+ * matches at the starting position of the input, or at the position immediately
319
+ * following a `\n` character.
320
+ */
321
+ export type LookStartLFVariant = {
322
+ '@type': 'enum'
323
+ '@name': 'regex_syntax::hir:Look'
324
+ '@variant': 'StartLF'
325
+ }
326
+
327
+ /**
328
+ * Match the end of a line or the end of text. Specifically, this matches at the
329
+ * end position of the input, or at the position immediately preceding a `\n`
330
+ * character.
331
+ */
332
+ export type LookEndLFVariant = {
333
+ '@type': 'enum'
334
+ '@name': 'regex_syntax::hir:Look'
335
+ '@variant': 'EndLF'
336
+ }
337
+
338
+ /**
339
+ * Match the beginning of a line or the beginning of text. Specifically, this
340
+ * matches at the starting position of the input, or at the position immediately
341
+ * following either a `\r` or `\n` character, but never after a `\r` when a `\n`
342
+ * follows.
343
+ */
344
+ export type LookStartCRLFVariant = {
345
+ '@type': 'enum'
346
+ '@name': 'regex_syntax::hir:Look'
347
+ '@variant': 'StartCRLF'
348
+ }
349
+
350
+ /**
351
+ * Match the end of a line or the end of text. Specifically, this matches at the
352
+ * end position of the input, or at the position immediately preceding a `\r` or
353
+ * `\n` character, but never before a `\n` when a `\r` precedes it.
354
+ */
355
+ export type LookEndCRLFVariant = {
356
+ '@type': 'enum'
357
+ '@name': 'regex_syntax::hir:Look'
358
+ '@variant': 'EndCRLF'
359
+ }
360
+
361
+ /**
362
+ * Match an ASCII-only word boundary. That is, this matches a position where the
363
+ * left adjacent character and right adjacent character correspond to a word and
364
+ * non-word or a non-word and word character.
365
+ */
366
+ export type LookWordAsciiVariant = {
367
+ '@type': 'enum'
368
+ '@name': 'regex_syntax::hir:Look'
369
+ '@variant': 'WordAscii'
370
+ }
371
+
372
+ /**
373
+ * Match an ASCII-only negation of a word boundary.
374
+ */
375
+ export type LookWordAsciiNegateVariant = {
376
+ '@type': 'enum'
377
+ '@name': 'regex_syntax::hir:Look'
378
+ '@variant': 'WordAsciiNegate'
379
+ }
380
+
381
+ /**
382
+ * Match a Unicode-aware word boundary. That is, this matches a position where
383
+ * the left adjacent character and right adjacent character correspond to a word
384
+ * and non-word or a non-word and word character.
385
+ */
386
+ export type LookWordUnicodeVariant = {
387
+ '@type': 'enum'
388
+ '@name': 'regex_syntax::hir:Look'
389
+ '@variant': 'WordUnicode'
390
+ }
391
+
392
+ /**
393
+ * Match a Unicode-aware negation of a word boundary.
394
+ */
395
+ export type LookWordUnicodeNegateVariant = {
396
+ '@type': 'enum'
397
+ '@name': 'regex_syntax::hir:Look'
398
+ '@variant': 'WordUnicodeNegate'
399
+ }
400
+
401
+ /**
402
+ * The high-level intermediate representation of a repetition operator.
403
+ *
404
+ * A repetition operator permits the repetition of an arbitrary sub-expression
405
+ */
406
+ export type Repetition = {
407
+ '@type': 'struct'
408
+ '@name': 'regex_syntax::hir::Repetition'
409
+
410
+ /**
411
+ * The minimum range of the repetition.
412
+ *
413
+ * Note that special cases like `?`, `+` and `*` all get translated into the
414
+ * ranges `{0,1}`, `{1,}` and `{0,}`, respectively.
415
+ *
416
+ * When `min` is zero, this expression can match the empty string regardless
417
+ * of what its sub-expression is.
418
+ */
419
+ min: number
420
+
421
+ /**
422
+ * The maximum range of the repetition.
423
+ *
424
+ * Note that when `max` is `undefined`, `min` acts as a lower bound but where
425
+ * there is no upper bound. For something like `x{5}` where the min and max
426
+ * are equivalent, `min` will be set to `5` and `max` will be set to `5`.
427
+ */
428
+ max?: number
429
+
430
+ /**
431
+ * Whether this repetition operator is greedy or not. A greedy operator will
432
+ * match as much as it can. A non-greedy operator will match as little as it
433
+ * can.
434
+ *
435
+ * Typically, operators are greedy by default and are only non-greedy when a
436
+ * `?` suffix is used, e.g., `(expr)*` is greedy while `(expr)*?` is not.
437
+ * However, this can be inverted via the `U` “ungreedy” flag.
438
+ */
439
+ greedy: boolean
440
+
441
+ /**
442
+ * The expression being repeated.
443
+ */
444
+ sub: Hir
445
+ }
446
+
447
+ /**
448
+ * Captures represents a group of captured strings for a single match.
449
+ *
450
+ * The 0th capture always corresponds to the entire match. Each subsequent index
451
+ * corresponds to the next capture group in the regex. If a capture group is named,
452
+ * then the matched string is also available via the name property. (Note that the
453
+ * 0th capture is always unnamed and so must be accessed with the get property.)
454
+ *
455
+ * Positions returned from a capture group are always byte indices.
456
+ */
457
+ export type Captures = {
458
+ get: Match[]
459
+ name: Record<string, Match>
460
+ }
461
+
462
+ /**
463
+ * The high-level intermediate representation for a capturing group.
464
+ *
465
+ * A capturing group always has an index and a child expression. It may also
466
+ * have a name associated with it (e.g., `(?P<foo>\w)`), but it's not necessary.
467
+ *
468
+ * Note that there is no explicit representation of a non-capturing group in a
469
+ * `Hir`. Instead, non-capturing grouping is handled automatically by the
470
+ * recursive structure of the `Hir` itself.
471
+ */
472
+ export type Capture = {
473
+ '@type': 'struct'
474
+ '@name': 'regex_syntax::hir::Capture'
475
+
476
+ /** The capture index of the capture. */
477
+ index: number
478
+
479
+ /** The name of the capture, if it exists. */
480
+ name?: String
481
+
482
+ /** The expression inside the capturing group, which may be empty. */
483
+ sub: Hir
484
+ }
485
+
486
+ /**
487
+ * A compiled regular expression for matching Unicode strings.
488
+ * @see https://docs.rs/regex/latest/regex/
489
+ */
490
+ export class RRegex {
491
+ free(): void;
492
+ /**
493
+ * Returns the same as is_match, but starts the search at the given offset.
494
+ * The significance of the starting point is that it takes the surrounding
495
+ * context into consideration. For example, the `\A` anchor can only match
496
+ * when `start == 0`.
497
+ *
498
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.is_match_at
499
+ * @param {string} text - The string against which to match the regular expression
500
+ * @param {number} start - Zero-based index at which to start matching
501
+ * @return {boolean}
502
+ */
503
+ isMatchAt(text: string, start: number): boolean;
504
+ /**
505
+ * Replaces all non-overlapping matches in `text` with the replacement
506
+ * provided. This is the same as calling `replacen` with `limit` set to
507
+ * `0`.
508
+ *
509
+ * See the documentation for `replace` for details on how to access
510
+ * capturing group matches in the replacement string.
511
+ *
512
+ * See the documentation for `replace` for details on how to access capturing group matches in the replacement string.
513
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.replace_all
514
+ * @param {string} text - The string against which to match the regular expression
515
+ * @param {string} rep - It's a string, it will replace the substring matched by `pattern`.
516
+ * @returns {string}
517
+ */
518
+ replaceAll(text: string, rep: string): string;
519
+ /**
520
+ * Returns a list with all the non-overlapping capture groups matched
521
+ * in `text`. This is operationally the same as `findAll`, except it
522
+ * returns information about capturing group matches.
523
+ *
524
+ * # Example
525
+ *
526
+ * We can use this to find all movie titles and their release years in
527
+ * some text, where the movie is formatted like "'Title' (xxxx)":
528
+ *
529
+ * ```typescript
530
+ * const re = new Regex("'(?P<title>[^']+)'\\s+\\((?P<year>\\d{4})\\)")
531
+ * const text = "'Citizen Kane' (1941), 'The Wizard of Oz' (1939), 'M' (1931)."
532
+ * for caps of re.captures_iter(text) {
533
+ * console.log(
534
+ * "Movie:", caps.name["title"].value, ","
535
+ * "Released:", caps.name["year"].value
536
+ * );
537
+ * }
538
+ * // Output:
539
+ * // Movie: Citizen Kane, Released: 1941
540
+ * // Movie: The Wizard of Oz, Released: 1939
541
+ * // Movie: M, Released: 1931
542
+ * ```
543
+ *
544
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.captures_iter
545
+ * @param {string} text - The string against which to match the regular expression
546
+ * @returns {Captures[]}
547
+ */
548
+ capturesAll(text: string): Captures[];
549
+ /**
550
+ * Returns the number of captures.
551
+ *
552
+ * This includes all named and unnamed groups, including the implicit
553
+ * unnamed group that is always present and corresponds to the entire match.
554
+ *
555
+ * Since the implicit unnamed group is always included in this length, the
556
+ * length returned is guaranteed to be greater than zero.
557
+ *
558
+ * ## Example
559
+ *
560
+ * ```typescript
561
+ * const re1 = new RRegex("(?P<y>\\d{4})-(?P<m>\\d{2})-(?P<d>\\d{2})")
562
+ * expect(re1.capturesLength()).toEqual(4)
563
+ *
564
+ * const re2 = new RRegex("foo")
565
+ * expect(re2.capturesLength()).toEqual(1)
566
+ *
567
+ * const re3 = new RRegex("(foo)")
568
+ * expect(re3.capturesLength()).toEqual(2)
569
+ *
570
+ * const re4 = new RRegex("(?<a>.(?<b>.))(.)(?:.)(?<c>.)")
571
+ * expect(re4.capturesLength()).toEqual(5)
572
+ *
573
+ * const re5 = new RRegex("[a&&b]")
574
+ * expect(re5.capturesLength()).toEqual(1)
575
+ * ```
576
+ *
577
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.captures_len
578
+ */
579
+ capturesLength(): number;
580
+ /**
581
+ * Returns a list of the capture names in this regex.
582
+ *
583
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.capture_names
584
+ */
585
+ captureNames(): (string | null)[];
586
+ /**
587
+ * Returns the end location of a match in the text given.
588
+ *
589
+ * This method may have the same performance characteristics as
590
+ * `isMatch`, except it provides an end location for a match. In
591
+ * particular, the location returned *may be shorter* than the proper end
592
+ * of the leftmost-first match that you would find via `Regex.find`.
593
+ *
594
+ * Note that it is not guaranteed that this routine finds the shortest or
595
+ * "earliest" possible match. Instead, the main idea of this API is that
596
+ * it returns the offset at the point at which the internal regex engine
597
+ * has determined that a match has occurred. This may vary depending on
598
+ * which internal regex engine is used, and thus, the offset itself may
599
+ * change.
600
+ *
601
+ * # Example
602
+ *
603
+ * Typically, `a+` would match the entire first sequence of `a` in some
604
+ * text, but `shortest_match` can give up as soon as it sees the first
605
+ * `a`.
606
+ *
607
+ * ```typescript
608
+ * const text = "aaaaa"
609
+ * const = new Regex("a+").shortest_match(text)
610
+ * expect(pos).toBe(1)
611
+ * ```
612
+ *
613
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.shortest_match
614
+ * @param {string} text - The string against which to match the regular expression
615
+ * @returns {number|undefined}
616
+ */
617
+ shortestMatch(text: string): number | undefined;
618
+ /**
619
+ * Returns the same as `shortest_match`, but starts the search at the
620
+ * given offset.
621
+ *
622
+ * The significance of the starting point is that it takes the surrounding
623
+ * context into consideration. For example, the `\A` anchor can only match
624
+ * when `start == 0`.
625
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.shortest_match_at
626
+ * @param {string} text - The string against which to match the regular expression
627
+ * @param {number} start - Zero-based index at which to start matching
628
+ * @returns {number|undefined}
629
+ */
630
+ shortestMatchAt(text: string, start: number): number | undefined;
631
+ /**
632
+ * Compiles a regular expression. Once compiled, it can be used repeatedly
633
+ * to search, split or replace text in a string.
634
+ *
635
+ * If an invalid expression is given, then an error is returned.
636
+ */
637
+ constructor(re: string);
638
+ /**
639
+ * Returns the start and end byte range of the leftmost-first match in
640
+ * `text`. If no match exists, then `undefined` is returned.
641
+ *
642
+ * Note that this should only be used if you want to discover the position
643
+ * of the match. Testing the existence of a match is faster if you use
644
+ * `isMatch`.
645
+ *
646
+ * # Example
647
+ *
648
+ * Find the start and end location of the first word with exactly 13
649
+ * Unicode word characters:
650
+ *
651
+ * ```typescript
652
+ * const text = "I categorically deny having triskaidekaphobia."
653
+ * const m = new Regex("\\b\\w{13}\\b").find(text)
654
+ * expect(m.start).toBe(2)
655
+ * expect(m.end).toBe(15)
656
+ * ```
657
+ *
658
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.find
659
+ * @param {string} text - The string against which to match the regular expression
660
+ * @return {Match}
661
+ */
662
+ find(text: string): Match | undefined;
663
+ /**
664
+ * Returns an iterator of substrings of `text` delimited by a match of the
665
+ * regular expression. Namely, each element of the iterator corresponds to
666
+ * text that *isn't* matched by the regular expression.
667
+ *
668
+ * This method will *not* copy the text given.
669
+ *
670
+ * # Example
671
+ *
672
+ * To split a string delimited by arbitrary amounts of spaces or tabs:
673
+ *
674
+ * ```typescript
675
+ * const re = new Regex(r"[ \\t]+")
676
+ * const fields = re.split("a b \t c\td e")
677
+ * expect(fields).toEqual(["a", "b", "c", "d", "e"])
678
+ * ```
679
+ *
680
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.split
681
+ * @param {string} text - The string against which to match the regular expression
682
+ * @returns {string[]}
683
+ */
684
+ split(text: string): string[];
685
+ /**
686
+ * Returns an iterator of at most `limit` substrings of `text` delimited
687
+ * by a match of the regular expression. (A `limit` of `0` will return no
688
+ * substrings.) Namely, each element of the iterator corresponds to text
689
+ * that *isn't* matched by the regular expression. The remainder of the
690
+ * string that is not split will be the last element in the iterator.
691
+ *
692
+ * This method will *not* copy the text given.
693
+ *
694
+ * # Example
695
+ *
696
+ * Get the first two words in some text:
697
+ *
698
+ * ```typescript
699
+ * const re = new Regex(r"\\W+")
700
+ * const fields = re.splitn("Hey! How are you?", 3)
701
+ * expect(fields).toEqual(["Hey", "How", "are you?"])
702
+ * ```
703
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.splitn
704
+ * @param {string} text - The string against which to match the regular expression
705
+ * @param {number} limit - Max number result elements
706
+ * @returns {string[]}
707
+ */
708
+ splitn(text: string, limit: number): string[];
709
+ /**
710
+ * Returns the regular expression into a high level intermediate
711
+ * representation.
712
+ */
713
+ syntax(): Hir;
714
+ /**
715
+ * Returns the same as find, but starts the search at the given
716
+ * offset.
717
+ *
718
+ * The significance of the starting point is that it takes the surrounding
719
+ * context into consideration. For example, the `\A` anchor can only
720
+ * match when `start == 0`.
721
+ *
722
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.find_at
723
+ * @param {string} text - The string against which to match the regular expression
724
+ * @param {number} start - Zero-based index at which to start matching
725
+ * @returns {Match}
726
+ */
727
+ findAt(text: string, start: number): Match | undefined;
728
+ /**
729
+ * Replaces the leftmost-first match with the replacement provided.
730
+ * The replacement can be a regular string (where `$N` and `$name` are
731
+ * expanded to match capture groups) or a function that takes the matches'
732
+ * `Captures` and returns the replaced string.
733
+ *
734
+ * If no match is found, then a copy of the string is returned unchanged.
735
+ *
736
+ * # Replacement string syntax
737
+ *
738
+ * All instances of `$name` in the replacement text is replaced with the
739
+ * corresponding capture group `name`.
740
+ *
741
+ * `name` may be an integer corresponding to the index of the
742
+ * capture group (counted by order of opening parenthesis where `0` is the
743
+ * entire match) or it can be a name (consisting of letters, digits or
744
+ * underscores) corresponding to a named capture group.
745
+ *
746
+ * If `name` isn't a valid capture group (whether the name doesn't exist
747
+ * or isn't a valid index), then it is replaced with the empty string.
748
+ *
749
+ * The longest possible name is used. e.g., `$1a` looks up the capture
750
+ * group named `1a` and not the capture group at index `1`. To exert more
751
+ * precise control over the name, use braces, e.g., `${1}a`.
752
+ *
753
+ * To write a literal `$` use `$$`.
754
+ *
755
+ * # Examples
756
+ *
757
+ * Note that this function is polymorphic with respect to the replacement.
758
+ * In typical usage, this can just be a normal string:
759
+ *
760
+ * ```typescript
761
+ * const re = new Regex("[^01]+")
762
+ * expect(re.replace("1078910", "").toBe("1010")
763
+ * ```
764
+ *
765
+ * Here's the example using this expansion technique with named capture
766
+ * groups:
767
+ *
768
+ * ```typescript
769
+ * const re = new Regex("(?P<last>[^,\\s]+),\\s+(?P<first>\\S+)")
770
+ * const result = re.replace("Springsteen, Bruce", "$first $last")
771
+ * expect(result).toBe("Bruce Springsteen")
772
+ * ```
773
+ *
774
+ * Note that using `$2` instead of `$first` or `$1` instead of `$last`
775
+ * would produce the same result. To write a literal `$` use `$$`.
776
+ *
777
+ * Sometimes the replacement string requires use of curly braces to
778
+ * delineate a capture group replacement and surrounding literal text.
779
+ * For example, if we wanted to join two words together with an
780
+ * underscore:
781
+ *
782
+ * ```typescript
783
+ * const re = new Regex("(?P<first>\\w+)\\s+(?P<second>\\w+)")
784
+ * const result = re.replace("deep fried", "${first}_$second")
785
+ * expect(result).toBe("deep_fried")
786
+ * ```
787
+ *
788
+ * Without the curly braces, the capture group name `first_` would be
789
+ * used, and since it doesn't exist, it would be replaced with the empty
790
+ * string.
791
+ *
792
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.replace
793
+ * @param {string} text - The string against which to match the regular expression
794
+ * @param {string} rep - It's a string, it will replace the substring matched by `pattern`.
795
+ * @returns {string}
796
+ */
797
+ replace(text: string, rep: string): string;
798
+ /**
799
+ * Returns the capture groups corresponding to the leftmost-first
800
+ * match in `text`. Capture group `0` always corresponds to the entire
801
+ * match. If no match is found, then `undefined` is returned.
802
+ *
803
+ * You should only use `captures` if you need access to the location of
804
+ * capturing group matches. Otherwise, `find` is faster for discovering
805
+ * the location of the overall match.
806
+ *
807
+ * # Examples
808
+ *
809
+ * Say you have some text with movie names and their release years,
810
+ * like "'Citizen Kane' (1941)". It'd be nice if we could search for text
811
+ * looking like that, while also extracting the movie name and its release
812
+ * year separately.
813
+ *
814
+ * ```typescript
815
+ * const re = new Regex("'([^']+)'\\s+\\((\\d{4})\)")
816
+ * const text = "Not my favorite movie: 'Citizen Kane' (1941)."
817
+ * const caps = re.captures(text)
818
+ * expect(caps.get[1].value).toBe("Citizen Kane")
819
+ * expect(caps.get[2].value).toBe("1941")
820
+ * expect(caps.get[0].value).toBe("'Citizen Kane' (1941)")
821
+ * ```
822
+ *
823
+ * Note that the full match is at capture group `0`. Each subsequent
824
+ * capture group is indexed by the order of its opening `(`.
825
+ *
826
+ * We can make this example a bit clearer by using *named* capture groups:
827
+ *
828
+ * ```typescript
829
+ * const re = new Regex("'(?P<title>[^']+)'\\s+\\((?P<year>\\d{4})\)")
830
+ * const text = "Not my favorite movie: 'Citizen Kane' (1941)."
831
+ * const caps = re.captures(text)
832
+ * expect(caps.name["title"].value).toBe("Citizen Kane")
833
+ * expect(caps.name["year"].value).toBe("1941")
834
+ * expect(caps.get[0].value).toBe("'Citizen Kane' (1941)")
835
+ * ```
836
+ *
837
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.captures
838
+ * @param {string} text - The string against which to match the regular expression
839
+ * @returns {Captures|undefined}
840
+ */
841
+ captures(text: string): Captures | undefined;
842
+ /**
843
+ * Returns an array for each successive non-overlapping match in `text``,
844
+ * returning the start and end byte indices with respect to `text`.
845
+ *
846
+ * # Example
847
+ *
848
+ * Find the start and end location of every word with exactly 13 Unicode
849
+ * word characters:
850
+ *
851
+ * ```typescript
852
+ * const text = "Retroactively relinquishing remunerations is reprehensible."
853
+ * const matches = new Regex("\\b\\w{13}\\b").findAll(text)
854
+ * ```
855
+ *
856
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.find_iter
857
+ * @param {string} text - The string against which to match the regular expression
858
+ * @returns {Match}
859
+ */
860
+ findAll(text: string): Match[];
861
+ /**
862
+ * Returns true if and only if there is a match for the regex in the
863
+ * string given.
864
+ *
865
+ * It is recommended to use this method if all you need to do is test
866
+ * a match, since the underlying matching engine may be able to do less
867
+ * work.
868
+ *
869
+ * # Example
870
+ *
871
+ * Test if some text contains at least one word with exactly 13
872
+ * Unicode word characters:
873
+ *
874
+ * ```typescript
875
+ * const text = "I categorically deny having triskaidekaphobia."
876
+ * expect(new RRegex("\\b\\w{13}\\b").is_match(text)).toBe(true)
877
+ * ```
878
+ *
879
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.is_match
880
+ * @param {string} text - The string against which to match the regular expression
881
+ * @return {boolean}
882
+ */
883
+ isMatch(text: string): boolean;
884
+ /**
885
+ * Replaces at most `limit` non-overlapping matches in `text` with the
886
+ * replacement provided. If `limit` is 0, then all non-overlapping matches
887
+ * are replaced.
888
+ *
889
+ * See the documentation for `replace` for details on how to access
890
+ * capturing group matches in the replacement string.
891
+ *
892
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.replacen
893
+ * @param {string} text - The string against which to match the regular expression
894
+ * @param {number} limit - Max number of replacement
895
+ * @param {string} rep - It's a string, it will replace the substring matched by `pattern`.
896
+ * @returns {string}
897
+ */
898
+ replacen(text: string, limit: number, rep: string): string;
899
+ /**
900
+ * Returns a string representing the regular expression
901
+ */
902
+ toString(): string;
903
+ }
904
+ /**
905
+ * Match multiple (possibly overlapping) regular expressions in a single scan.
906
+ * A regex set corresponds to the union of two or more regular expressions.
907
+ *
908
+ * That is, a regex set will match text where at least one of its constituent
909
+ * regular expressions matches. A regex set as its formulated here provides a
910
+ * touch more power: it will also report which regular expressions in the set match.
911
+ * Indeed, this is the key difference between regex sets and a single `Regex`
912
+ * with many alternates, since only one alternate can match at a time.
913
+ *
914
+ * @see https://docs.rs/regex/latest/regex/struct.RegexSet.html#method.empty
915
+ */
916
+ export class RRegexSet {
917
+ free(): void;
918
+ /**
919
+ * Create a new regex set with the given regular expressions.
920
+ *
921
+ * This takes an of strings, if any item in the list is not a valid regular
922
+ * expressions, then an error is returned.
923
+ *
924
+ * # Example
925
+ *
926
+ * Create a new regex set from an iterator of strings:
927
+ *
928
+ * ```typescript
929
+ * const set = new RegexSet(["\\w+", "\\d+"])
930
+ * expect(set.is_match("foo")).toBe(true)
931
+ * ```
932
+ */
933
+ constructor(list: Array<any>);
934
+ /**
935
+ * Returns the set of regular expressions that match in the given text.
936
+ *
937
+ * The set returned contains the index of each regular expression that
938
+ * matches in the given text. The index is in correspondence with the
939
+ * order of regular expressions given to `RegexSet`'s constructor.
940
+ *
941
+ * The set can also be used to iterate over the matched indices.
942
+ *
943
+ * Note that as with searches using `Regex`, the expression is unanchored
944
+ * by default. That is, if the regex does not start with `^` or `\A`, or
945
+ * end with `$` or `\z`, then it is permitted to match anywhere in the
946
+ * text.
947
+ *
948
+ * # Example
949
+ *
950
+ * Tests which regular expressions match the given text:
951
+ *
952
+ * ```typescript
953
+ * const set = new RegexSet([
954
+ * "\\w+",
955
+ * "\\d+",
956
+ * "\\pL+",
957
+ * "foo",
958
+ * "bar",
959
+ * "barfoo",
960
+ * "foobar",
961
+ * ])
962
+ * const matches = set.matches("foobar")
963
+ * expect(matches).toBe([0, 2, 3, 4, 6])
964
+ * ```
965
+ *
966
+ * @see https://docs.rs/regex/latest/regex/struct.RegexSet.html#method.matches
967
+ * @param {string} text - The string against which to match the regular expression
968
+ * @return {number[]}
969
+ */
970
+ matches(text: string): number[];
971
+ /**
972
+ * Returns true if and only if one of the regexes in this set matches
973
+ * the text given.
974
+ *
975
+ * This method should be preferred if you only need to test whether any
976
+ * of the regexes in the set should match, but don't care about *which*
977
+ * regexes matched. This is because the underlying matching engine will
978
+ * quit immediately after seeing the first match instead of continuing to
979
+ * find all matches.
980
+ *
981
+ * Note that as with searches using `Regex`, the expression is unanchored
982
+ * by default. That is, if the regex does not start with `^` or `\A`, or
983
+ * end with `$` or `\z`, then it is permitted to match anywhere in the
984
+ * text.
985
+ *
986
+ * # Example
987
+ *
988
+ * Tests whether a set matches some text:
989
+ *
990
+ * ```typescript
991
+ * const set = new RegexSet(["\\w+", "\\d+"])
992
+ * expect(set.is_match("foo")).toBe(true)
993
+ * expect(!set.is_match("☃")).toBe(false)
994
+ * ```
995
+ *
996
+ * @see https://docs.rs/regex/latest/regex/struct.RegexSet.html#method.is_match
997
+ * @param {string} text - The string against which to match the regular expression
998
+ * @return {boolean}
999
+ */
1000
+ isMatch(text: string): boolean;
1001
+ }