rregex 1.7.1 → 1.9.0

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