File tree Expand file tree Collapse file tree 3 files changed +13
-10
lines changed
packages/@rescript/runtime Expand file tree Collapse file tree 3 files changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -44,16 +44,10 @@ type result
4444An `array` of the match and captures, the first is the full match and the
4545remaining are the substring captures.
4646*/
47- @deprecated ({
48- reason : "Use `RegExp.Result.matches` instead." ,
49- migrate : RegExp .Result .matches (),
50- })
47+ @deprecated ("Use `RegExp.Result.t` instead." )
5148external captures : result => array <Js_null_undefined .t <string >> = "%identity"
5249
53- @deprecated ({
54- reason : "Use `RegExp.Result.matches` instead." ,
55- migrate : RegExp .Result .matches (),
56- })
50+ @deprecated ("Use `RegExp.Result.t` instead." )
5751external matches : result => array <string > = "%identity"
5852
5953/** 0-based index of the match in the input string. */
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ module Result = {
55 type t = array <option <string >>
66 @get_index external fullMatch : (t , @as (0 ) _ ) => string = ""
77 @send external matches : (t , @as (1 ) _ ) => array <option <string >> = "slice"
8+ @send external captures : (t , @as (1 ) _ ) => array <option <string >> = "slice"
89 @get external index : t => int = "index"
910 @get external input : t => string = "input"
1011}
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ module Result: {
3434 external fullMatch : (t , @as (0 ) _ ) => string = ""
3535
3636 /**
37- `matches (regExpResult)` returns all matches for `regExpResult`.
37+ `captures (regExpResult)` returns all capture groups for `regExpResult`.
3838
3939 ## Examples
4040 ```rescript
@@ -45,15 +45,23 @@ module Result: {
4545 switch regexp->RegExp.exec("ReScript is pretty cool, right?") {
4646 | None => Console.log("Nope, no match...")
4747 | Some(result) =>
48- switch result->RegExp.Result.matches ->Array.keepSome {
48+ switch result->RegExp.Result.captures ->Array.keepSome {
4949 | [firstWord, secondWord] => Console.log2(firstWord, secondWord)
5050 | _ => Console.log("Didn't find exactly two words...")
5151 }
5252 }
5353 ```
5454 */
5555 @send
56+ external captures : (t , @as (1 ) _ ) => array <option <string >> = "slice"
57+
58+ @deprecated ({
59+ reason : "Use `RegExp.Result.captures` instead." ,
60+ migrate : RegExp .Result .captures (),
61+ })
62+ @send
5663 external matches : (t , @as (1 ) _ ) => array <option <string >> = "slice"
64+
5765 @get external index : t => int = "index"
5866
5967 /**
You can’t perform that action at this time.
0 commit comments