diff --git a/CHANGELOG.md b/CHANGELOG.md index 26ccec0f..c670c153 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Next version +- BREAKING: Fixes the type of `RegExp.Result.t` to be `array>` instead of `array`. https://github.com/rescript-association/rescript-core/pull/233. + ## 0.7.0 - Add `Dict.getUnsafe` https://github.com/rescript-association/rescript-core/pull/167 diff --git a/src/Core__RegExp.res b/src/Core__RegExp.res index 84668ae0..119d199b 100644 --- a/src/Core__RegExp.res +++ b/src/Core__RegExp.res @@ -1,7 +1,7 @@ type t = Js.Re.t module Result = { - type t = array + type t = array> @get_index external fullMatch: (t, @as(0) _) => string = "" @send external matches: (t, @as(1) _) => array = "slice" @get external index: t => int = "index" diff --git a/src/Core__RegExp.resi b/src/Core__RegExp.resi index e16ba1e9..a469d07b 100644 --- a/src/Core__RegExp.resi +++ b/src/Core__RegExp.resi @@ -13,7 +13,7 @@ module Result: { /** Type representing the result of a `RegExp` execution. */ - type t = array + type t = array> /** `fullMatch(regExpResult)` returns the full string that matched in this result. diff --git a/src/Core__String.resi b/src/Core__String.resi index 89b574fa..f7158b27 100644 --- a/src/Core__String.resi +++ b/src/Core__String.resi @@ -413,10 +413,11 @@ See [`String.match`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Ref ## Examples ```rescript -String.match("The better bats", %re("/b[aeiou]t/")) == Some(["bet"]) -String.match("The better bats", %re("/b[aeiou]t/g")) == Some(["bet", "bat"]) +String.match("The better bats", %re("/b[aeiou]t/")) == Some([Some("bet")]) +String.match("The better bats", %re("/b[aeiou]t/g")) == Some([Some("bet"), Some("bat")]) String.match("Today is 2018-04-05.", %re("/(\d+)-(\d+)-(\d+)/")) == - Some(["2018-04-05", "2018", "04", "05"]) + Some([Some("2018-04-05"), Some("2018"), Some("04"), Some("05")]) +String.match("The optional example", %re("/(foo)?(example)/")) == Some([Some("example"), None, Some("example")]) String.match("The large container.", %re("/b[aeiou]g/")) == None ``` */