String-related functions
Defined in: core::strings
str_length
The length of a string.
fn str_length(s: String) -> Scalar
str_slice
Subslice of a string.
fn str_slice(s: String, start: Scalar, end: Scalar) -> String
chr
Get a single-character string from a Unicode code point. Example: 0x2764 -> chr
.
fn chr(n: Scalar) -> String
ord
Get the Unicode code point of the first character in a string. Example: "❤" -> ord
.
fn ord(s: String) -> Scalar
lowercase
Convert a string to lowercase.
fn lowercase(s: String) -> String
uppercase
Convert a string to uppercase.
fn uppercase(s: String) -> String
str_append
Concatenate two strings.
fn str_append(a: String, b: String) -> String
str_find
Find the first occurrence of a substring in a string.
fn str_find(haystack: String, needle: String) -> Scalar
str_contains
Check if a string contains a substring.
fn str_contains(haystack: String, needle: String) -> Bool
str_replace
Replace all occurrences of a substring in a string.
fn str_replace(s: String, pattern: String, replacement: String) -> String
str_repeat
Repeat the input string n
times.
fn str_repeat(a: String, n: Scalar) -> String
base
Convert a number to the given base. Example: 42 |> base(16)
.
fn base(b: Scalar, x: Scalar) -> String
bin
Get a binary representation of a number. Example: 42 -> bin
.
fn bin(x: Scalar) -> String
oct
Get an octal representation of a number. Example: 42 -> oct
.
fn oct(x: Scalar) -> String
dec
Get a decimal representation of a number.
fn dec(x: Scalar) -> String
hex
Get a hexadecimal representation of a number. Example: 2^31-1 -> hex
.
fn hex(x: Scalar) -> String