Press the spacebar to start.

Module String

module String: sig .. end
String operations.

A string is an immutable data structure that contains a fixed-length sequence of (single-byte) characters. Each character can be accessed in constant time through its index.

Given a string s of length l, we can access each of the l characters of s via its index in the sequence. Indexes start at 0, and we will call an index valid in s if it falls within the range [0...l-1] (inclusive). A position is the point between two characters or at the beginning or end of the string. We call a position valid in s if it falls within the range [0...l] (inclusive). Note that the character at index n is between positions n and n+1.

Two parameters start and len are said to designate a valid substring of s if len >= 0 and start and start+len are valid positions in s.

Note: OCaml strings used to be modifiable in place, for instance via the String.set and String.blit functions described below. This usage is only possible when the compiler is put in "unsafe-string" mode by giving the -unsafe-string command-line option. This compatibility mode makes the types string and bytes (see module Bytes) interchangeable so that functions expecting byte sequences can also accept strings as arguments and modify them.

The distinction between bytes and string was introduced in OCaml 4.02, and the "unsafe-string" compatibility mode was the default until OCaml 4.05. Starting with 4.06, the compatibility mode is opt-in; we intend to remove the option in the future.

Loading, please wait
Tags
Name
Argument 1
Argument 2
Argument 3
Argument 4
Argument 5
Return Type
Usage Count
Coresetbytesintchar unit19,965
Corefillbytesintintcharunit1,009
Coresplit_on_charcharstring string list3,720
Functional Iteratorsof_seqchar Seq.t t85
Corecreateint bytes15,854
Coremakeintchar string46,643
Coreinitint(int -> char) string2,685
Corelengthstring int109,761
Corecopystring string2,239
Coretrimstring string4,253
Coreescapedstring string6,775
Coreuppercasestring string3,945
Corelowercasestring string10,740
Corecapitalizestring string7,952
Coreuncapitalizestring string2,938
Coreuppercase_asciistring string1,082
Corelowercase_asciistring string2,953
Corecapitalize_asciistring string2,809
Coreuncapitalize_asciistring string883
Coreindexstringchar int15,812
Coreindex_optstringchar int option483
Corerindexstringchar int5,345
Corerindex_optstringchar int option315
Corecontainsstringchar bool9,168
Coregetstringint char19,933
Coreblitstringintbytesintintunit6,302
Coreindex_fromstringintchar int4,204
Coreindex_from_optstringintchar int option283
Corerindex_fromstringintchar int1,330
Corerindex_from_optstringintchar int option239
Corecontains_fromstringintchar bool811
Corercontains_fromstringintchar bool728
Coresubstringintint string50,519
Coreconcatstringstring list string63,302
Functional Iteratorsto_seqt char Seq.t218
Functional Iteratorsto_seqit (int * char) Seq.t10
Corecomparett int11,381
Coreequaltt bool9,270
Coremap(char -> char)string string14,487
Coreiter(char -> unit)string unit4,935
Coremapi(int -> char -> char)string string467
Coreiteri(int -> char -> unit)string unit382