package devkit

  1. Overview
  2. Docs

More string functions

val by_words : Pcre.regexp
val by_space : Pcre.regexp
val by_lines : Pcre.regexp
val split : Pcre.regexp -> string -> string list
val nsplitc_enum : string -> char -> string Devkit_core.Prelude.Enum.t
val nsplitc_fold : string -> char -> ('a -> string -> 'a) -> 'a -> 'a
val nsplitc_rev : string -> char -> string list
val nsplitc : string -> char -> string list
val countc : string -> char -> int
val from_to : string -> int -> int -> string

from_to s a b

  • returns

    substring of s from position a (including) up to position b (excluding).

val unsafe_from_to : string -> int -> int -> string

from_to without safety checks

val upto : string -> int -> string

upto s p

  • returns

    prefix of s up to position p (excluding)

val from : string -> int -> string

from s p

  • returns

    suffix of s from position p (including)

val slice : ?first:int -> ?last:int -> string -> string

safe (lazy) way to cut substring same as extlib String.slice

val splitc : string -> char -> string * string

split by delimiter

val rsplitc : string -> char -> string * string

split by delimiter from the right

val before : string -> string -> string

before s sep

  • returns

    substring from the beginning of s to the delimiter sep or the original string if delimiter is not present. NB before s "" -> "" e.g. before "a.b.c" "." -> "a"

val after : string -> string -> string
  • returns

    substring from the delimiter sep to the end of string s or the empty string if delimiter is not present. e.g. after "a.b.c" "." -> "b.c" NB after s "" -> s invariant: if s contains sep then before s sep ^ sep ^ after s sep = s else before s sep ^ after s sep = s or put it another way: say a = before s sep and b = after s sep then before (a ^ sep ^ b) sep = a and after (a ^ sep ^ b) sep = b

val divide : string -> string -> string * string
  • returns

    (before s sep, after s sep) divide s sep is equal to String.split but doesn't throw if sep is not a substring of s

val dividec : string -> char -> string * string
val qreplace : string -> string -> string -> string
val replace_all : str:string -> sub:string -> by:string -> string
val extract : Pcre.regexp -> string -> string option

contents of the first submatch

val starts_with : string -> ?pos:int -> string -> bool

String.starts_with but with pos to start from

val ends_with : string -> string -> bool
val exists : string -> string -> bool
val drop_prefix : string -> string -> string

remove prefix from string if present

val drop_suffix : string -> string -> string
val istarts_with : string -> ?pos:int -> string -> bool
val iequal : string -> string -> bool

ascii case-insensitive equality

val equal : string -> string -> bool
val iexists : string -> string -> bool

ascii case-insensitive substring

sequence of matches

val enum_extract : Pcre.regexp -> string -> string Devkit_core.Prelude.Enum.t
module ASCII : sig ... end
val rev : string -> string
val common_prefix : string -> string -> int
val shorten : ?escape:bool -> int -> string -> string
val array_concat : string -> string array -> string
val rstrip : ?chars:string -> string -> string
val catmap : ?sep:string -> ('a -> string) -> 'a list -> string
val list : ('a -> string) -> 'a list -> string
val array : ('a -> string) -> 'a array -> string
OCaml

Innovation. Community. Security.