package spotlib

  1. Overview
  2. Docs
include module type of struct include Stdlib.String end
val length : string -> int
val get : string -> int -> char
val set : bytes -> int -> char -> unit
  • deprecated Use Bytes.set instead.
val create : int -> bytes
  • deprecated Use Bytes.create instead.
val make : int -> char -> string
val init : int -> (int -> char) -> string
val copy : string -> string
  • deprecated
val sub : string -> int -> int -> string
val fill : bytes -> int -> int -> char -> unit
  • deprecated Use Bytes.fill instead.
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 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
  • deprecated Use String.uppercase_ascii instead.
val lowercase : string -> string
  • deprecated Use String.lowercase_ascii instead.
val capitalize : string -> string
  • deprecated Use String.capitalize_ascii instead.
val uncapitalize : string -> string
  • deprecated Use String.uncapitalize_ascii instead.
val uppercase_ascii : string -> string
val lowercase_ascii : string -> string
val capitalize_ascii : string -> string
val uncapitalize_ascii : string -> string
type t = string
val compare : t -> t -> int
val equal : t -> t -> bool
val split_on_char : char -> string -> string list
val to_seq : t -> char Stdlib.Seq.t
val to_seqi : t -> (int * char) Stdlib.Seq.t
val of_seq : char Stdlib.Seq.t -> t
val unsafe_get : string -> int -> char
val unsafe_set : bytes -> int -> char -> unit
  • deprecated
val unsafe_blit : string -> int -> bytes -> int -> int -> unit
val unsafe_fill : bytes -> int -> int -> char -> unit
  • deprecated
include module type of struct include Xstring end

Construction

val make1 : char -> string

make1 = String.make 1

val of_char : char -> string

Sysnonym make1

Deconstruction

val to_array : string -> char array
val to_code_array : string -> int array

Array

val get_opt : string -> int -> char option
val scani_left : (int -> 'a -> char -> [< `Continue of 'a | `Stop of 'a ]) -> 'a -> ?from:int -> ?to_:int -> string -> 'a
val foldi_left : (int -> 'a -> char -> [< `Continue of 'a | `Stop of 'a ]) -> 'a -> string -> 'a
val replace_chars : char -> char -> string -> string

replace_chars c1 c2 s returns a copy of s with replacing all the char occurrences of c1 by c2.

Transform

val chop_eols : string -> string

chop_eols s returns the string s w/o the end-of-line chars. chop from Perl. chop_eols "hello\r\n" = "hello" chop_eols "hello\n" = "hello" chop_eols "hello\r" = "hello" chop_eols "hello" = "hello"

Sub

val sub_from_to : string -> int -> int -> string
val sub' : string -> int -> int -> string

Same as String.sub but even if the string shorter for len the function succeeds and returns a shorter substring.

val is_substring : ?from:int -> needle:string -> string -> bool
val is_sub : ?from:int -> needle:string -> string -> bool
val is_prefix : ?from:int -> string -> string -> bool
val is_postfix : string -> string -> bool
val is_prefix' : ?from:int -> string -> string -> string option

Same as prefix but returns the postfix

val is_postfix' : string -> string -> string option

Same as postfix but returns the prefix

val index_from_to : string -> int -> int -> char -> int option
val index_string_from : string -> int -> string -> int
val split_at : int -> string -> string * string

Haskelish string sub

val take : int -> string -> string
val drop : int -> string -> string
val drop_postfix : int -> string -> string
val prefix : int -> string -> string

same as take

val postfix : int -> string -> string

Split

val lines : string -> (string * string) list

lines "hello\nworld\r\ngood\rday" = ["hello", "\n"; "world", "\r\n"; "good", "\r"; "day", ""]

val split : (char -> bool) -> string -> string list

split (function ' ' -> true | _ -> false) "hello world" = ["hello"; "world"]

val split1 : ?from:int -> (char -> bool) -> string -> (string * string) option

Same as split but do the split only once

val words : string -> string list

Split a string into "words" by white characters ' ', '\t', '\r' and '\n'

val index_opt : string -> char -> int option

Optionalized

val find : string -> int -> (char -> bool) -> int option

Random

val random : int -> string
val random_hum : int -> string

human readable

Misc

val is_space_or_tab : char -> bool
val is_newline_or_return : char -> bool

Stdlib

module Stdlib = Xstring.Stdlib

Set

module Set = Xstring.Set
OCaml

Innovation. Community. Security.