Module Unprime_string.String
include module type of Stdlib.String
val length : string -> int
val get : string -> int -> char
val set : bytes -> int -> char -> unit
val create : int -> bytes
val make : int -> char -> string
val init : int -> (int -> char) -> string
val copy : string -> string
val sub : string -> int -> int -> string
val fill : bytes -> int -> int -> char -> unit
val blit : string -> int -> bytes -> int -> int -> unit
val concat : string -> string list -> string
val iter : (char -> unit) -> string -> unit
val iteri : (int -> char -> unit) -> string -> unit
val map : (char -> char) -> string -> string
val mapi : (int -> char -> char) -> string -> string
val trim : string -> string
val escaped : string -> string
val index : string -> char -> int
val index_opt : string -> char -> int option
val rindex : string -> char -> int
val rindex_opt : string -> char -> int option
val index_from : string -> int -> char -> int
val index_from_opt : string -> int -> char -> int option
val rindex_from : string -> int -> char -> int
val rindex_from_opt : string -> int -> char -> int option
val contains : string -> char -> bool
val contains_from : string -> int -> char -> bool
val rcontains_from : string -> int -> char -> bool
val uppercase : string -> string
val lowercase : string -> string
val capitalize : string -> string
val uncapitalize : string -> string
val uppercase_ascii : string -> string
val lowercase_ascii : string -> string
val capitalize_ascii : string -> string
val uncapitalize_ascii : string -> string
include module type of Prime_string
Construction and Conversion
Iteration over Elements
val fold : (char -> 'a -> 'a) -> string -> 'a -> 'a
fold f s
isf s.[n - 1] ∘ ... ∘ f s[0]
wheren = length s
.
val foldi : (int -> char -> 'a -> 'a) -> string -> 'a -> 'a
foldi f s
isf (n - 1) s.[n - 1] ∘ ... ∘ f 0 s[0]
wheren = length s
.
val count : (char -> bool) -> string -> int
count f s
is the number of occurrences of a characters ins
which fulfilf
.
Search Primitives
val skip_while : (char -> bool) -> string -> int -> int
skip_while f s
increments a position until it reaches the end ofs
or it points to a character ins
on whichf
returns false. In other words ifj = skip_while f s i
, thenslice i j s
is the largest substring starting ati
on whichf
is constant true.
val skip_until : (char -> bool) -> string -> int -> int
skip_until f
is an optimisation ofskip_while (not ∘ f)
.
val rskip_while : (char -> bool) -> string -> int -> int
rskip_while f s
decrements a position as long as the result points to a character ins
on whichf
is true.
val rskip_until : (char -> bool) -> string -> int -> int
rskip_until f
is an optimization ofrskip_while (not ∘ f)
.
Substring Predicates
Slicing
val slice : int -> int -> string -> string
slice i j s
is the slice ofs
from positioni
up to but not includingj
.
val slice_from : int -> string -> string
slice_from i s
is a shortcut forslice i (String.length s) s
.
val cut_affix : string -> string -> (string * string) option
cut_affix afx s
returns the substrings before and after the leftmost occurrence ofafx
ins
orNone
ifafx
does not occur ins
.
val rcut_affix : string -> string -> (string * string) option
rcut_affix afx s
returns the substrings before and after the rightmost occurrence ofafx
ins
orNone
ifafx
does not occur ins
.
val chop_affix : string -> string -> string list
chop_affix afx s
returns the substrings before, between, and after matches ofafx
ins
, except forchop_affix afx ""
, which always gives[]
. In other wordschop_affix afx
provides a primitive way of extracting the operands of an infix operatorafx
. Ifafx
can overlap, it is unspecified which match is used.
val cut_consecutive : (char -> bool) -> string -> (string * string) option
cut_consecutive f s
returns the substrings before and after the leftmost consecutive sequence of bytes satisfyingf
, orNone
if notString.exists f s
.
val rcut_consecutive : (char -> bool) -> string -> (string * string) option
cut_consecutive f s
returns the substrings before and after the rightmost consecutive sequence of bytes satisfyingf
, orNone
if notString.exists f s
.
val chop_consecutive : (char -> bool) -> string -> string list
chop_consecutive f s
returns the non-empty substrings before, between, and after consecutive sequences of bytesc
for whichf c
is true. In particularchop_consecutive Char.is_space
is suitable for splitting words separated by ASCII white-spaces.