Commits

camlspotter  committed 497d3ef

added Utils.String.split_at

  • Participants
  • Parent commits e197e91

Comments (0)

Files changed (2)

     let len = max (min (pos + len) orig_len - pos) 0 in
     sub s pos len
 
+  let split_at s pos = sub s 0 pos, sub s pos (length s - pos)
+
   let test () =
     assert (sub' "hello" 0 4 = "hell");
     assert (sub' "hello" 0 5 = "hello");
       the function succeeds and returns a shorter substring. 
   *)
 
+  val split_at : string -> int -> string * string
+  (** Get prefix and postfix. May raise an error when out of bound. *)
+
   val find : string -> int -> (char -> bool) -> int option
 
   val replace_chars : char -> char -> string -> string