Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Next version

- 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.

## 1.4.0

- Add `RegExp.setLastIndex` function. https://github.com/rescript-association/rescript-core/pull/219
Expand Down
2 changes: 1 addition & 1 deletion src/Core__RegExp.res
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
type t = Js.Re.t

module Result = {
type t = array<string>
type t = array<option<string>>
@get_index external fullMatch: (t, @as(0) _) => string = ""
@send external matches: (t, @as(1) _) => array<string> = "slice"
@get external index: t => int = "index"
Expand Down
2 changes: 1 addition & 1 deletion src/Core__RegExp.resi
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module Result: {
/**
Type representing the result of a `RegExp` execution.
*/
type t = array<string>
type t = array<option<string>>

/**
`fullMatch(regExpResult)` returns the full string that matched in this result.
Expand Down
7 changes: 4 additions & 3 deletions src/Core__String.resi
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
*/
Expand Down