Skip to content

Commit 494ac01

Browse files
weakishcristianoc
authored andcommitted
fixup! Update Js.String[2].match_ return type
1 parent 0251131 commit 494ac01

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

pages/docs/manual/latest/api/js/string-2.mdx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -318,21 +318,20 @@ Js.String2.localeCompare("CAT", "cat") > 0.0
318318
let match_: (t, Js_re.t) => option<array<option<t>>>
319319
```
320320

321-
`match(regexp, str)` matches a `string` against the given `regexp`. If there is no match, it returns `None`. For regular expressions without the g modifier, if there is a match, the return value is `Some(array)` where the array contains:
321+
`match(str, regexp)` matches a `string` against the given `regexp`. If there is no match, it returns `None`. For regular expressions without the g modifier, if there is a match, the return value is `Some(array)` where the array contains:
322322
- The entire matched string
323323
- Any capture groups if the regexp had parentheses
324324

325325
For regular expressions with the g modifier, a matched expression returns `Some(array)` with all the matched substrings and no capture groups. Javscript String.prototype.match can return `undefined` for optional capture groups that are not found, thus the element of the returned array is typed `option<t>`. See [`String.match`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match) on MDN.
326326

327327
```res example
328-
Js.String.match_(%re("/b[aeiou]t/"), "The better bats") == Some([Some("bet")])
329-
Js.String.match_(%re("/b[aeiou]t/g"), "The better bats") == Some([Some("bet"), Some("bat")])
330-
Js.String.match_(%re("/(\d+)-(\d+)-(\d+)/"), "Today is 2018-04-05.") ==
328+
Js.String2.match_("The better bats", %re("/b[aeiou]t/")) == Some([Some("bet")])
329+
Js.String2.match_("The better bats", %re("/b[aeiou]t/g")) == Some([Some("bet"), Some("bat")])
330+
Js.String2.match_("Today is 2018-04-05.", %re("/(\d+)-(\d+)-(\d+)/")) ==
331331
Some([Some("2018-04-05"), Some("2018"), Some("04"), Some("05")])
332-
Js.String.match_(%re("/b[aeiou]g/"), "The large container.") == None
332+
Js.String2.match_("The large container.", %re("/b[aeiou]g/")) == None
333333
```
334334

335-
336335
## normalize
337336

338337
```res sig

0 commit comments

Comments
 (0)