String
is the string data type for representing text.
allocated?
(Fn [(Ref String a)] Bool)
(allocated? s)
checks if a String returned by String.allocate is not NULL. This is a safeguard against out-of-memory conditions.
alpha?
(Fn [(Ref String a)] Bool)
(alpha? s)
checks whether a string contains only alphabetical characters (a-Z).
ascii-to-lower
(Fn [(Ref String a)] String)
(ascii-to-lower s)
converts each character in this string to lower case using tolower() from standard C library. Note: this will only work for ASCII characters.
ascii-to-upper
(Fn [(Ref String a)] String)
(ascii-to-upper s)
converts each character in this string to upper case using toupper() from standard C library. Note: this will only work for ASCII characters.
collapse-whitespace
(Fn [(Ref String a)] String)
(collapse-whitespace s)
collapses groups of whitespace into single spaces.
concat
(Fn [(Ref (Array String) a)] String)
(concat strings)
Returns a new string which is the concatenation of the provided strings
.
contains?
(Fn [(Ref String a), Char] Bool)
(contains? s c)
Checks whether the string s
contains the character c
.
count-char
(Fn [(Ref String a), Char] Int)
(count-char s c)
Returns the number of occurrences of c
in the string s
.
ends-with?
(Fn [(Ref String a), (Ref String b)] Bool)
(ends-with? s sub)
Check if the string s
ends with the string sub
.
in?
(Fn [(Ref String a), (Ref String b)] Bool)
(in? s sub)
checks whether a string contains another string.
join
(Fn [(Ref String a), (Ref (Array String) b)] String)
(join sep strings)
Returns a new string which is the concatenation of the provided strings
separated by string sep
.
join-with-char
(Fn [Char, (Ref (Array String) a)] String)
(join-with-char sep strings)
Returns a new string which is the concatenation of the provided strings
separated by char sep
.
pad-left
(Fn [Int, Char, (Ref String a)] String)
(pad-left len pad s)
Pads the left of a string with len bytes using the padding pad.
pad-right
(Fn [Int, Char, (Ref String a)] String)
(pad-right len pad s)
Pads the right of a string with len bytes using the padding pad.
prefix
(Fn [(Ref String a), Int] String)
(prefix s a)
Return the first a
characters of the string s
.
repeat
(Fn [Int, (Ref String a)] String)
(repeat n inpt)
Returns a new string which is inpt
repeated n
times.
slice
(Fn [(Ref String a), Int, Int] String)
(slice s a b)
Return part of a string, beginning at index a
and ending at index b
.
split-by
(Fn [(Ref String a), (Ref (Array Char) b)] (Array String))
(split-by s separators)
splits a string by separators.
starts-with?
(Fn [(Ref String a), (Ref String b)] Bool)
(starts-with? s sub)
Check if the string s
begins with the string sub
.
suffix
(Fn [(Ref String a), Int] String)
(suffix s b)
Returns the suffix string starting at the b
th character.
sum-length
(Fn [(Ref (Array String) a)] Int)
(sum-length strings)
Returns the sum of lengths from an array of Strings.
trim-left
(Fn [(Ref String a)] String)
(trim-left s)
trims whitespace from the left of a string.
trim-right
(Fn [(Ref String a)] String)
(trim-right s)
trims whitespace from the right of a string.