package conex

  1. Overview
  2. Docs

Module Conex_utils.StringSource

Some String utilities implemented here to avoid external dependencies. This is a subset of Astring.

Sourcetype t = string

Our string type is an OCaml string

Sourceval cuts : char -> t -> t list

cuts sep str separates str into multiple substrings, stripping out the separating character sep. String.concat "/" (String.cuts '/' xs) is the identity.

Sourceval cut : char -> t -> (t * t) option

cut sep str cuts the string str at the first occurence of sep into its left and right parts. If sep is not found, None is returned. If Some (a, b) is returned, a ^ sep ^ b is equal to str.

Sourceval is_prefix : prefix:t -> t -> bool

is_prefix ~prefix str is true if str begins with prefix, false otherwise.

Sourceval is_suffix : suffix:t -> t -> bool

is_suffix ~suffix str is true if str ends with suffix, false otherwise.

Sourceval slice : ?start:int -> ?stop:int -> t -> t

slice ~start ~stop str slices str into a smaller piece, starting at offset start (default 0), ending at stop (default String.length).

Sourceval to_lower : t -> t

to_lower str converts all printable ASCII characters to lowercase.

Sourceval is_ascii : ?p:(char -> bool) -> t -> bool

is_ascii ~p str is true if all characters in str are ASCII characters: 0-9, a-z, A-Z OR satisfy p. Otherwise false.

Sourceval trim : t -> t

trim str removes leading and trailing whitespaces of str.

Sourceval get : t -> int -> char

get str offset retrieves the character at offset in str.

Sourceval concat : t -> t list -> t

concat sep xs concatenates all xs, using sep as separator.

Sourceval compare : t -> t -> int

compare a b compares a with b using String.compare.

Sourceval length : t -> int

length str is the byte length of str.

Sourceval compare_insensitive : t -> t -> int

compare_insensitive a b first converts a and b to lowercase strings, then uses compare.

Sourceval equal : t -> t -> bool

equal a b is String.equal a b.

OCaml

Innovation. Community. Security.