Skip to content

Commit 199633b

Browse files
fix: RegExp.Result.t should be an array of options (#234)
1 parent 0b4bd00 commit 199633b

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Next version
44

5+
- BREAKING: Fixes the type of `RegExp.Result.t` to be `array<option<string>>` instead of `array<string>`. https://github.com/rescript-association/rescript-core/pull/234.
6+
57
## 1.4.0
68

79
- Add `RegExp.setLastIndex` function. https://github.com/rescript-association/rescript-core/pull/219

src/Core__RegExp.res

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
type t = Js.Re.t
22

33
module Result = {
4-
type t = array<string>
4+
type t = array<option<string>>
55
@get_index external fullMatch: (t, @as(0) _) => string = ""
66
@send external matches: (t, @as(1) _) => array<string> = "slice"
77
@get external index: t => int = "index"

src/Core__RegExp.resi

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module Result: {
1313
/**
1414
Type representing the result of a `RegExp` execution.
1515
*/
16-
type t = array<string>
16+
type t = array<option<string>>
1717

1818
/**
1919
`fullMatch(regExpResult)` returns the full string that matched in this result.

src/Core__String.resi

+4-3
Original file line numberDiff line numberDiff line change
@@ -429,10 +429,11 @@ See [`String.match`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Ref
429429
## Examples
430430

431431
```rescript
432-
String.match("The better bats", %re("/b[aeiou]t/")) == Some(["bet"])
433-
String.match("The better bats", %re("/b[aeiou]t/g")) == Some(["bet", "bat"])
432+
String.match("The better bats", %re("/b[aeiou]t/")) == Some([Some("bet")])
433+
String.match("The better bats", %re("/b[aeiou]t/g")) == Some([Some("bet"), Some("bat")])
434434
String.match("Today is 2018-04-05.", %re("/(\d+)-(\d+)-(\d+)/")) ==
435-
Some(["2018-04-05", "2018", "04", "05"])
435+
Some([Some("2018-04-05"), Some("2018"), Some("04"), Some("05")])
436+
String.match("The optional example", %re("/(foo)?(example)/")) == Some([Some("example"), None, Some("example")])
436437
String.match("The large container.", %re("/b[aeiou]g/")) == None
437438
```
438439
*/

0 commit comments

Comments
 (0)