diff --git a/CHANGELOG.md b/CHANGELOG.md index fec92a21..6d29a73e 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/234. + ## 1.4.0 - Add `RegExp.setLastIndex` function. https://github.com/rescript-association/rescript-core/pull/219 diff --git a/src/Core__RegExp.res b/src/Core__RegExp.res index 441b328a..9f19af81 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 4e42be94..3e12daef 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 7558adf8..b3e429ba 100644 --- a/src/Core__String.resi +++ b/src/Core__String.resi @@ -429,10 +429,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 ``` */