From f67dc664b8d042dee07459bc460457971c50e700 Mon Sep 17 00:00:00 2001 From: Yawar Amin Date: Sun, 14 Jan 2018 20:38:31 -0500 Subject: [PATCH] Js.String.replace: add doc comment The order of the function arguments is potentially confusing, so document it. --- jscomp/others/js_string.ml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/jscomp/others/js_string.ml b/jscomp/others/js_string.ml index 1d7ed3ddb7..01fa530b95 100644 --- a/jscomp/others/js_string.ml +++ b/jscomp/others/js_string.ml @@ -78,6 +78,20 @@ external normalizeByForm : t -> t = "normalize" [@@bs.send.pipe: t] (** ES2015 * external repeat : int -> t = "" [@@bs.send.pipe: t] (** ES2015 *) external replace : t -> t -> t = "" [@@bs.send.pipe: t] + +(** [replace substr newSubstr string] returns a new string which is +identical to [string] except with the first matching instance of [substr] +replaced by [newSubstr]. + +[substr] is treated as a verbatim string to match, not a regular +expression. + +@example {[ +let result = Js.String.replace "a" "b" "aaaa" +let () = Js.log result (* prints "baaa" *) +]} +*) + external replaceByRe : Js_re.t -> t -> t = "replace" [@@bs.send.pipe: t] (** returns a new string with some or all matches of a pattern replaced by the