Std.String
Unicode string operations: slicing, searching, casing, and more.
Functions
length
fun length : (s: String) -> IntReturns the number of grapheme clusters in the string.
is_empty
fun is_empty : String -> BoolReturns True if the string is empty.
graphemes
fun graphemes : (s: String) -> List StringSplits a string into its individual grapheme clusters.
trim
fun trim : (s: String) -> StringRemoves leading and trailing whitespace.
to_lower
fun to_lower : (s: String) -> StringConverts all characters to lowercase.
to_upper
fun to_upper : (s: String) -> StringConverts all characters to uppercase.
reverse
fun reverse : (s: String) -> StringReverses the string.
slice
fun slice : (start: Int) -> (len: Int) -> (s: String) -> StringExtracts a substring starting at the given index for the given length.
find
fun find : (sub: String) -> (s: String) -> Maybe StringFinds the first occurrence of a substring, returning it and the rest.
strip_prefix
fun strip_prefix : (prefix: String) -> (s: String) -> Maybe StringStrips a prefix from the string, returning the rest or Nothing.
contains
fun contains : (sub: String) -> (s: String) -> BoolReturns True if the string contains the substring.
starts_with
fun starts_with : (prefix: String) -> (s: String) -> BoolReturns True if the string starts with the given prefix.
ends_with
fun ends_with : (suffix: String) -> (s: String) -> BoolReturns True if the string ends with the given suffix.
split
fun split : (sep: String) -> (s: String) -> List StringSplits a string by a separator into a list of parts.
replace
fun replace : (pattern: String) -> (replacement: String) -> (s: String) -> StringReplaces the first occurrence of a pattern with a replacement.
replace_all
fun replace_all : (pattern: String) -> (replacement: String) -> (s: String) -> StringReplaces all occurrences of a pattern with a replacement.
join
fun join : (sep: String) -> (parts: List String) -> StringJoins a list of strings with a separator.
is_alpha
fun is_alpha : (s: String) -> BoolReturns True if all characters are alphabetic (a-z, A-Z).
is_digit
fun is_digit : (s: String) -> BoolReturns True if all characters are digits (0-9).
is_alphanumeric
fun is_alphanumeric : (s: String) -> BoolReturns True if all characters are alphanumeric (a-z, A-Z, 0-9).
is_upper
fun is_upper : (s: String) -> BoolReturns True if all characters are uppercase (A-Z).
is_lower
fun is_lower : (s: String) -> BoolReturns True if all characters are lowercase (a-z).
is_whitespace
fun is_whitespace : (s: String) -> BoolReturns True if all characters are whitespace.
byte_size
fun byte_size : String -> IntReturns the length of the raw bytes of the string.
repeat
fun repeat : (n: Int) -> (s: String) -> StringRepeats a string n times.
pad_left
fun pad_left : (width: Int) -> (fill: String) -> (s: String) -> StringPads a string on the left to the given width using the fill string.
pad_right
fun pad_right : (width: Int) -> (fill: String) -> (s: String) -> StringPads a string on the right to the given width using the fill string.