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