package opam-core

  1. Overview
  2. Docs

Module OpamStd.StringSource

Collections

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

Set of string sets

Sourcemodule SetMap : MAP with type key = Set.t

Map of string sets

Checks

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

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

Manipulation

Sourceval map : (char -> char) -> string -> string
Sourceval strip : string -> string
Sourceval strip_right : string -> string
Sourceval sub_at : int -> string -> string
Sourceval remove_prefix : prefix:string -> string -> string
Sourceval remove_suffix : suffix:string -> string -> string
Sourceval 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
Sourceval cut_at : string -> char -> (string * string) option

Cut a string at the first occurrence of the given char

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

Same as cut_at, but starts from the right

Sourceval split : string -> char -> string list

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

Sourceval split_delim : string -> char -> string list

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

Sourceval 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"]

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

Innovation. Community. Security.