let rex = Pcre.regexp "\\s*$" in
fun s -> Pcre.replace ~rex s
+let split ?(char = ' ') s =
+ let pieces = ref [] in
+ let rec aux idx =
+ match (try Some (String.index_from s idx char) with Not_found -> None) with
+ | Some pos ->
+ pieces := String.sub s idx (pos - idx) :: !pieces;
+ aux (pos + 1)
+ | None -> pieces := String.sub s idx (String.length s - idx) :: !pieces
+ in
+ aux 0;
+ List.rev !pieces
+
let empty_mathml () =
DomMisc.domImpl#createDocument ~namespaceURI:(Some DomMisc.mathml_ns)
~qualifiedName:(Gdome.domString "math") ~doctype:None
val strip_trailing_blanks: string -> string
val strip_trailing_slash: string -> string
+ (* split a string at character, char defaults to ' ' *)
+val split: ?char:char -> string -> string list
+
val list_uniq: 'a list -> 'a list (* uniq unix filter on lists *)
(** @raise Failure *)