Return a copy of the argument, with all lowercase letters translated to uppercase, including accented letters of the ISO Latin-1 (8859-1) character set.
deprecated
Functions operating on Latin-1 character set are deprecated.
val lowercase : string -> string
Return a copy of the argument, with all uppercase letters translated to lowercase, including accented letters of the ISO Latin-1 (8859-1) character set.
deprecated
Functions operating on Latin-1 character set are deprecated.
val capitalize : string -> string
Return a copy of the argument, with the first character set to uppercase, using the ISO Latin-1 (8859-1) character set..
deprecated
Functions operating on Latin-1 character set are deprecated.
val uncapitalize : string -> string
Return a copy of the argument, with the first character set to lowercase, using the ISO Latin-1 (8859-1) character set.
deprecated
Functions operating on Latin-1 character set are deprecated.
blit src src_pos dst dst_pos len copies len characters from string src starting at character indice src_pos, to the Bytes sequence dst starting at character indice dst_pos. Like String.blit. Compatible with the -safe-string option.
val is_sub : sub:string ->int ->string ->int ->sub_len:int -> bool
is_sub ~sub ~sub_pos s ~pos ~sub_len returns true iff the substring of sub starting at position sub_pos and of length sub_len is a substring of s starting at position pos.
val repeat : string ->int -> string
repeat s n creates a string by repeating the string sn times.
val prefix : pre:string ->string -> bool
prefix ~pre s returns true iff pre is a prefix of s.
val suffix : suf:string ->string -> bool
suffix ~suf s returns true iff suf is a suffix of s.
since 0.7
val chop_prefix : pre:string ->string ->string option
chop_prefix ~pre s removes pre from s if pre really is a prefix of s, returns None otherwise.
since 0.17
val chop_suffix : suf:string ->string ->string option
chop_suffix ~suf s removes suf from s if suf really is a suffix of s, returns None otherwise.
since 0.17
val take : int ->string -> string
take n s keeps only the n first chars of s.
since 0.17
val drop : int ->string -> string
drop n s removes the n first chars of s.
since 0.17
val take_drop : int ->string -> string * string
take_drop n s is take n s, drop n s.
since 0.17
val lines : string ->string list
lines s returns a list of the lines of s (splits along '\n').
iter f s applies function f on each character of s. Alias to String.iter.
since 0.12
val filter_map : (char ->char option)->string -> string
filter_map f s calls (f a0) (f a1) … (f an) where a0 … an are the characters of s. It returns the string of characters ci such as f ai = Some ci (when f returns None, the corresponding element of s is discarded).
since 0.17
val filter : (char -> bool)->string -> string
filter f s discards characters of s not satisfying f.
since 0.17
val uniq : (char ->char -> bool)->string -> string
uniq eq s remove consecutive duplicate characters in s.
since 3.4
val flat_map : ?sep:string ->(char -> string)->string -> string
flat_map ~sep f s maps each chars of s to a string, then concatenates them all.
parametersep
optional separator between each generated string.
since 0.12
val for_all : (char -> bool)->string -> bool
for_all f s is true iff all characters of s satisfy the predicate f.
since 0.12
val exists : (char -> bool)->string -> bool
exists f s is true iff some character of s satisfy the predicate f.
split_on_char by s splits the string s along the given char by.
since 1.2
val split : by:string ->string ->string list
split ~by s splits the string s along the given string by. Alias to Split.list_cpy.
since 1.2
Utils
val compare_versions : string ->string -> int
compare_versions s1 s2 compares version stringss1 and s2, considering that numbers are above text.
since 0.13
val compare_natural : string ->string -> int
compare_natural s1 s2 is the Natural Sort Order, comparing chunks of digits as natural numbers. https://en.wikipedia.org/wiki/Natural_sort_order
since 1.3
val edit_distance : ?cutoff:int ->string ->string -> int
edit_distance ~cutoff s1 s2 is the edition distance between the two strings s1 and s2. This satisfies the classical distance axioms: it is always positive, symmetric, and satisfies the formula distance s1 s2 + distance s2 s3 >= distance s1 s3.
parametercutoff
if provided, it's a cap on the number of iterations. (since 3.0). This is useful if you just want to check whether the edit distance is less or equal than 2 without (use edit_distance s1 s2 ~cutoff:3 <= 2). note that contrary to what was previously documented here, the result can still be higher than cutoff if it's reached in <cutoff iterations. However if the result is < cutoff then it is accurate.