@@ -432,11 +432,11 @@ on MDN.
432
432
## Examples
433
433
434
434
```rescript
435
- Js.String2.match_("The better bats", %re(" /b[aeiou]t/") ) == Some(["bet"])
436
- Js.String2.match_("The better bats", %re(" /b[aeiou]t/g") ) == Some(["bet", "bat"])
437
- Js.String2.match_("Today is 2018-04-05.", %re(" /(\d+)-(\d+)-(\d+)/") ) ==
435
+ Js.String2.match_("The better bats", /b[aeiou]t/) == Some(["bet"])
436
+ Js.String2.match_("The better bats", /b[aeiou]t/g) == Some(["bet", "bat"])
437
+ Js.String2.match_("Today is 2018-04-05.", /(\d+)-(\d+)-(\d+)/) ==
438
438
Some(["2018-04-05", "2018", "04", "05"])
439
- Js.String2.match_("The large container.", %re(" /b[aeiou]g/") ) == None
439
+ Js.String2.match_("The large container.", /b[aeiou]g/) == None
440
440
```
441
441
*/
442
442
external match_ : (t , Js_re .t ) => option <array <option <t >>> = "match"
@@ -516,8 +516,8 @@ on MDN.
516
516
## Examples
517
517
518
518
```rescript
519
- Js.String2.replaceByRe("vowels be gone", %re(" /[aeiou]/g") , "x") == "vxwxls bx gxnx"
520
- Js.String2.replaceByRe("Juan Fulano", %re(" /(\w+) (\w+)/") , "$2, $1") == "Fulano, Juan"
519
+ Js.String2.replaceByRe("vowels be gone", /[aeiou]/g, "x") == "vxwxls bx gxnx"
520
+ Js.String2.replaceByRe("Juan Fulano", /(\w+) (\w+)/, "$2, $1") == "Fulano, Juan"
521
521
```
522
522
*/
523
523
external replaceByRe : (t , Js_re .t , t ) => t = "replace"
@@ -536,7 +536,7 @@ on MDN.
536
536
537
537
```rescript
538
538
let str = "beautiful vowels"
539
- let re = %re(" /[aeiou]/g")
539
+ let re = /[aeiou]/g
540
540
let matchFn = (matchPart, _offset, _wholeString) => Js.String2.toUpperCase(matchPart)
541
541
542
542
Js.String2.unsafeReplaceBy0(str, re, matchFn) == "bEAUtIfUl vOwEls"
@@ -559,7 +559,7 @@ on MDN.
559
559
560
560
```rescript
561
561
let str = "Jony is 40"
562
- let re = %re(" /(Jony is )\d+/g")
562
+ let re = /(Jony is )\d+/g
563
563
let matchFn = (_match, part1, _offset, _wholeString) => {
564
564
part1 ++ "41"
565
565
}
@@ -584,7 +584,7 @@ on MDN.
584
584
585
585
```rescript
586
586
let str = "7 times 6"
587
- let re = %re(" /(\d+) times (\d+)/")
587
+ let re = /(\d+) times (\d+)/
588
588
let matchFn = (_match, p1, p2, _offset, _wholeString) => {
589
589
switch (Belt.Int.fromString(p1), Belt.Int.fromString(p2)) {
590
590
| (Some(x), Some(y)) => Belt.Int.toString(x * y)
@@ -621,8 +621,8 @@ on MDN.
621
621
## Examples
622
622
623
623
```rescript
624
- Js.String2.search("testing 1 2 3", %re(" /\d+/") ) == 8
625
- Js.String2.search("no numbers", %re(" /\d+/") ) == -1
624
+ Js.String2.search("testing 1 2 3", /\d+/) == 8
625
+ Js.String2.search("no numbers", /\d+/) == -1
626
626
```
627
627
*/
628
628
external search : (t , Js_re .t ) => int = "search"
@@ -709,7 +709,7 @@ on MDN.
709
709
## Examples
710
710
711
711
```rescript
712
- Js.String2.splitByRe("art; bed , cog ;dad", %re(" /\s*[,;]\s*TODO/") ) == [
712
+ Js.String2.splitByRe("art; bed , cog ;dad", /\s*[,;]\s*TODO/) == [
713
713
Some("art"),
714
714
Some("bed"),
715
715
Some("cog"),
@@ -732,15 +732,15 @@ on MDN.
732
732
## Examples
733
733
734
734
```rescript
735
- Js.String2.splitByReAtMost("one: two: three: four", %re(" /\s*:\s*TODO/") , ~limit=3) == [
735
+ Js.String2.splitByReAtMost("one: two: three: four", /\s*:\s*TODO/, ~limit=3) == [
736
736
Some("one"),
737
737
Some("two"),
738
738
Some("three"),
739
739
]
740
740
741
- Js.String2.splitByReAtMost("one: two: three: four", %re(" /\s*:\s*TODO/") , ~limit=0) == []
741
+ Js.String2.splitByReAtMost("one: two: three: four", /\s*:\s*TODO/, ~limit=0) == []
742
742
743
- Js.String2.splitByReAtMost("one: two: three: four", %re(" /\s*:\s*TODO/") , ~limit=8) == [
743
+ Js.String2.splitByReAtMost("one: two: three: four", /\s*:\s*TODO/, ~limit=8) == [
744
744
Some("one"),
745
745
Some("two"),
746
746
Some("three"),
0 commit comments