Commits

Peter Szilagyi committed 2024e4c

Documented Regex.replace's global semantics.

  • Participants
  • Parent commits f8dd3c2

Comments (0)

Files changed (2)

ocaml/omake/lib/regex.ml

 
 type t = Pcre.regexp
 let of_string s = Pcre.regexp s
+
 let rewrite rex ~template s = Pcre.replace ~rex ~templ:template s
+TEST = rewrite (of_string "a") ~template:"b" "abcabc" = "bbcbbc"
+
 let has_match rex s = Pcre.pmatch ~rex s
 type id_t = [ `Index of int | `Name of string ]
 type match_ = Pcre.substrings

ocaml/omake/lib/regex.mli

 
 type t
 
+(** [rewrite t ~template s] replaces all occurrences of [t] in [s] with
+    [template]. *)
 val rewrite : t -> template:string -> string -> string
+
 val has_match : t -> string -> bool
 
 type id_t = [ `Index of int | `Name of string ]