String Support

Denys Duchier

module
x-oz://system/String.ozf

This module provides additional convenience operation on strings. It should not be confused, with the base String which is always present and does not need to be imported.

Exports

{String.make +VS ?S}
turns a virtual string into a plain old regular string
{String.length +S ?N}
returns the length N of string S
{String.toInt +S ?I}
takes a string S and returns the integer I of which it is the textual representation
{String.toFloat +S ?F}
takes a string S and returns the float F of which it is the textual representation
{String.toInt +S ?A}
takes a string S and returns the corresponding atom A
{String.capitalize +S1 ?S2}
takes a string S1 and returns a string S2 which is identical except for the first letter which has been capitalized
{String.split +S +Sep ?L}
splits string S at all occurrences of string Sep and returns the resulting list L. Sep may also be unit in which case splits occur at all non-empty sequences of whitespace characters. It can also be nil, in which case splits occur between every two characters
{String.splitAtMost +S +Sep +N ?L}
same as above, but at most N splits are performed: the remainder of the string is returned as the last element of list L
{String.lstrip +S1 +Chars ?S2}
takes a string S1 and returns a string S2 where all characters at the left of S1 which are in Chars have been removed. Chars can also be unit, in which case it stands for all whitespace characters
{String.rstrip +S1 +Chars ?S2}
same thing but at the right-end of S1
{String.strip +S1 +Chars ?S2}
same thing at both ends
{String.replace +S1 +Old +New ?S2}
replace every occurrence of string Old in S1 by New
{String.replaceAtMost +S1 +Old +New +N ?S2}
same as above, but replace at most N occurrences of Old