package opam-core

  1. Overview
  2. Docs

Collections

module Map : MAP with type key = string
module Set : SET with type elt = string
module SetSet : SET with type elt = Set.t

Set of string sets

module SetMap : MAP with type key = Set.t

Map of string sets

Checks

val starts_with : prefix:string -> string -> bool
val ends_with : suffix:string -> string -> bool
val for_all : (char -> bool) -> string -> bool
val contains_char : string -> char -> bool
val contains : sub:string -> string -> bool
val exact_match : Re.re -> string -> bool
val find_from : (char -> bool) -> string -> int -> int
val compare_case : string -> string -> int

Like String.compare, but with lowercase/uppercase variants ordered next to each other (still considered not equal though)

Manipulation

val map : (char -> char) -> string -> string
val strip : string -> string
val strip_right : string -> string
val sub_at : int -> string -> string
val remove_prefix : prefix:string -> string -> string
val remove_suffix : suffix:string -> string -> string
val is_prefix_of : from:int -> full:string -> string -> bool

is_prefix_of from full str returns true if str if a prefix of full, with at least from first characters

Transformations
val cut_at : string -> char -> (string * string) option

Cut a string at the first occurrence of the given char

val rcut_at : string -> char -> (string * string) option

Same as cut_at, but starts from the right

val split : string -> char -> string list

Split a string at occurrences of a given characters. Empty strings are skipped.

val split_delim : string -> char -> string list

The same as split, but keep empty strings (leading, trailing or between contiguous delimiters)

val split_quoted : string -> char -> string list

Splits a variable at the given character, but allowing double-quote characters to protect the delimiter.

split_quoted "foo\";\"bar;baz" ';' = ["foo;bar"; "baz"]

val fold_left : ('a -> char -> 'a) -> 'a -> string -> 'a
val is_hex : string -> bool
OCaml

Innovation. Community. Security.