let str = "hello world!"
let re = [%re "/hello/g"]
let replaced = Js.String.unsafeReplaceBy0 re (fun match offset whole -> "hi")
let () = Js.log replaced (* prints "hi world!" *)
val unsafeReplaceBy1 : Js_re.t -> (t -> t -> int -> t -> t) -> t -> t
returns a new string with some or all matches of a pattern replaced by the
value returned from the given function
let str = "hello world!"
let re = [%re "/hello/g"]
let replaced = Js.String.unsafeReplaceBy1 re (fun match p1 offset whole -> "hi")
let () = Js.log replaced (* prints "hi world!" *)
val unsafeReplaceBy2 : Js_re.t -> (t -> t -> t -> int -> t -> t) -> t -> t
returns a new string with some or all matches of a pattern replaced by the
value returned from the given function
let str = "hello world!"
let re = [%re "/hello/g"]
let replaced = Js.String.unsafeReplaceBy2 re (fun match p1 p2 offset whole -> "hi")
let () = Js.log replaced (* prints "hi world!" *)
val unsafeReplaceBy3 : Js_re.t -> (t -> t -> t -> t -> int -> t -> t) -> t -> t
returns a new string with some or all matches of a pattern replaced by the
value returned from the given function
let str = "hello world!"
let re = [%re "/hello/g"]
let replaced = Js.String.unsafeReplaceBy3 re (fun match p1 p2 p3 offset whole -> "hi")
let () = Js.log replaced (* prints "hi world!" *)