replace ~sub ~by s replaces some occurrences of sub by by in s.
parameterwhich
decides whether the occurrences to replace are:
`Left first occurrence from the left (beginning).
`Right first occurrence from the right (end).
`All all occurrences (default).
raisesInvalid_argument
if sub = "".
since 0.14
val is_sub : sub:string ->int ->string ->int ->sub_len:int -> bool
is_sub ~sub i s j ~sub_len returns true iff the substring of sub starting at position i and of length sub_len is a substring of s starting at position j.
val repeat : string ->int -> string
The same string, repeated n 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 = 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').
unlines_gen g concatenates all strings of g, separated with '\n'.
since 0.10
val set : string ->int ->char -> string
set s i c creates a new string which is a copy of s, except for index i, which becomes c.
raisesInvalid_argument
if i is an invalid index.
since 0.12
val iter : (char -> unit)->string -> unit
Alias to String.iter.
since 0.12
val iteri : (int ->char -> unit)->string -> unit
Iter on chars with their index.
since 0.12
val map : (char -> char)->string -> string
Map chars.
since 0.12
val mapi : (int ->char -> char)->string -> string
Map chars with their index.
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 not satisfying f.
since 0.17
val flat_map : ?sep:string ->(char -> string)->string -> string
Map each chars to a string, then concatenates them all.
compare_versions a b compares version strings a and b, considering that numbers are above text.
since 0.13
val compare_natural : string ->string -> int
Natural Sort Order, comparing chunks of digits as natural numbers. https://en.wikipedia.org/wiki/Natural_sort_order
since 1.3
val edit_distance : string ->string -> int
Edition distance between two strings. This satisfies the classical distance axioms: it is always positive, symmetric, and satisfies the formula distance a b + distance b c >= distance a c.