@@ -595,6 +595,7 @@ let matchFn = (~match, ~offset as _, ~input as _) => String.toUpperCase(match)
595595String.unsafeReplaceRegExpBy0(str, re, matchFn) == "bEAUtIfUl vOwEls" 
596596``` 
597597*/ 
598+ @deprecated ("Use `replaceRegExpBy0Unsafe` instead" )
598599@send 
599600external  unsafeReplaceRegExpBy0 : (
600601  string ,
@@ -618,6 +619,7 @@ let matchFn = (~match as _, ~group1, ~offset as _, ~input as _) => {
618619String.unsafeReplaceRegExpBy1(str, re, matchFn) == "Jony is 41" 
619620``` 
620621*/ 
622+ @deprecated ("Use `replaceRegExpBy1Unsafe` instead" )
621623@send 
622624external  unsafeReplaceRegExpBy1 : (
623625  string ,
@@ -644,6 +646,7 @@ let matchFn = (~match as _, ~group1, ~group2, ~offset as _, ~input as _) => {
644646String.unsafeReplaceRegExpBy2(str, re, matchFn) == "42" 
645647``` 
646648*/ 
649+ @deprecated ("Use `replaceRegExpBy2Unsafe` instead" )
647650@send 
648651external  unsafeReplaceRegExpBy2 : (
649652  string ,
@@ -652,10 +655,11 @@ external unsafeReplaceRegExpBy2: (
652655) =>  string  =  "replace" 
653656
654657/** 
655- `unsafeReplaceRegExpBy3(str, regexp, f)`. Like `unsafeReplaceRegExpBy1 `, but `f` 
658+ `unsafeReplaceRegExpBy3(str, regexp, f)`. Like `unsafeReplaceRegExpBy2 `, but `f` 
656659has three group parameters. 
657660See [`String.replace`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace) on MDN. 
658661*/ 
662+ @deprecated ("Use `replaceRegExpBy3Unsafe` instead" )
659663@send 
660664external  unsafeReplaceRegExpBy3 : (
661665  string ,
@@ -670,6 +674,98 @@ external unsafeReplaceRegExpBy3: (
670674  ) =>  string ,
671675) =>  string  =  "replace" 
672676
677+ /** 
678+ `replaceRegExpBy0Unsafe(str, regex, f)` returns a new `string` with some or all 
679+ matches of a pattern with no capturing parentheses replaced by the value 
680+ returned from the given function. The function receives as its parameters the 
681+ matched string, the offset at which the match begins, and the whole string being 
682+ matched. 
683+ See [`String.replace`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace) on MDN. 
684+ 
685+ ## Examples 
686+ 
687+ ```rescript 
688+ let str = "beautiful vowels" 
689+ let re = %re("/[aeiou]/g") 
690+ let matchFn = (~match, ~offset as _, ~input as _) => String.toUpperCase(match) 
691+ String.replaceRegExpBy0Unsafe(str, re, matchFn) == "bEAUtIfUl vOwEls" 
692+ ``` 
693+ */ 
694+ @send 
695+ external  replaceRegExpBy0Unsafe : (
696+   string ,
697+   Stdlib_RegExp .t ,
698+   (~match : string , ~offset : int , ~input : string ) =>  string ,
699+ ) =>  string  =  "replace" 
700+ 
701+ /** 
702+ `replaceRegExpBy1Unsafe(str, regexp, f)`. Like `replaceRegExpBy0Unsafe`, but `f` 
703+ has `group1` parameter. 
704+ See [`String.replace`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace) on MDN. 
705+ 
706+ ## Examples 
707+ 
708+ ```rescript 
709+ let str = "Jony is 40" 
710+ let re = %re("/(Jony is )\d+/g") 
711+ let matchFn = (~match as _, ~group1, ~offset as _, ~input as _) => { 
712+   group1 ++ "41" 
713+ } 
714+ String.replaceRegExpBy1Unsafe(str, re, matchFn) == "Jony is 41" 
715+ ``` 
716+ */ 
717+ @send 
718+ external  replaceRegExpBy1Unsafe : (
719+   string ,
720+   Stdlib_RegExp .t ,
721+   (~match : string , ~group1 : string , ~offset : int , ~input : string ) =>  string ,
722+ ) =>  string  =  "replace" 
723+ 
724+ /** 
725+ `replaceRegExpBy2Unsafe(str, regexp, f)`. Like `replaceRegExpBy1Unsafe`, but `f` 
726+ has two group parameters. 
727+ See [`String.replace`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace) on MDN. 
728+ 
729+ ## Examples 
730+ 
731+ ```rescript 
732+ let str = "7 times 6" 
733+ let re = %re("/(\d+) times (\d+)/") 
734+ let matchFn = (~match as _, ~group1, ~group2, ~offset as _, ~input as _) => { 
735+   switch (Int.fromString(group1), Int.fromString(group2)) { 
736+   | (Some(x), Some(y)) => Int.toString(x * y) 
737+   | _ => "???" 
738+   } 
739+ } 
740+ String.replaceRegExpBy2Unsafe(str, re, matchFn) == "42" 
741+ ``` 
742+ */ 
743+ @send 
744+ external  replaceRegExpBy2Unsafe : (
745+   string ,
746+   Stdlib_RegExp .t ,
747+   (~match : string , ~group1 : string , ~group2 : string , ~offset : int , ~input : string ) =>  string ,
748+ ) =>  string  =  "replace" 
749+ 
750+ /** 
751+ `replaceRegExpBy3Unsafe(str, regexp, f)`. Like `replaceRegExpBy2Unsafe`, but `f` 
752+ has three group parameters. 
753+ See [`String.replace`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace) on MDN. 
754+ */ 
755+ @send 
756+ external  replaceRegExpBy3Unsafe : (
757+   string ,
758+   Stdlib_RegExp .t ,
759+   (
760+     ~match : string ,
761+     ~group1 : string ,
762+     ~group2 : string ,
763+     ~group3 : string ,
764+     ~offset : int ,
765+     ~input : string ,
766+   ) =>  string ,
767+ ) =>  string  =  "replace" 
768+ 
673769/** 
674770`search(str, regexp)` returns the starting position of the first match of 
675771`regexp` in the given `str`, or -1 if there is no match. 
0 commit comments