Compares strings lexicographically.
| Type | Value |
| Input | Str | a string |
| other (param #1) | Str | another string |
| Output | Bool | true if the input appears before other in lexicographical order, false otherwise |
| Program | Type | Value | Error |
"a" <"b" | Bool | true | |
"Ab" <"A" | Bool | false | |
"cd" <"cd" | Bool | false | |
Compares strings lexicographically.
| Type | Value |
| Input | Str | a string |
| other (param #1) | Str | another string |
| Output | Bool | true if the input appears after other in lexicographical order, false otherwise |
| Program | Type | Value | Error |
"a" >"b" | Bool | false | |
"Ab" >"A" | Bool | true | |
"cd" >"cd" | Bool | false | |
Compares strings lexicographically.
| Type | Value |
| Input | Str | a string |
| other (param #1) | Str | another string |
| Output | Bool | true if the input appears before other in lexicographical order or is equal to it, false otherwise |
| Program | Type | Value | Error |
"a" <="b" | Bool | true | |
"Ab" <="A" | Bool | false | |
"cd" <="cd" | Bool | true | |
Compares strings lexicographically.
| Type | Value |
| Input | Str | a string |
| other (param #1) | Str | another string |
| Output | Bool | true if the input appears after other in lexicographical order or is equal to it, false otherwise |
| Program | Type | Value | Error |
"a" >="b" | Bool | false | |
"Ab" >="A" | Bool | true | |
"cd" >="cd" | Bool | true | |
Concatenates two strings.
| Type | Value |
| Input | Str | a string |
| b (param #1) | Str | another string |
| Output | Str | The input and b, concatenated. |
| Program | Type | Value | Error |
"ab" +"cd" | Str | "abcd" | |
"ab" +"" | Str | "ab" | |
"" +"cd" | Str | "cd" | |
Converts a string to bytes.
| Type | Value |
| Input | Str | a string |
| Output | Arr<Num...> | The UTF-8 bytes representing the string. |
| Program | Type | Value | Error |
"abc" bytes | Arr<Num...> | [97, 98, 99] | |
"Köln" bytes | Arr<Num...> | [75, 195, 182, 108, 110] | |
"日本語" bytes | Arr<Num...> | [230, 151, 165, 230, 156, 172, 232, 170, 158] | |
"\x00" bytes | Arr<Num...> | [0] | |
Converts bytes to a string.
| Type | Value |
| Input | Arr<Num...> | an array of numbers (interpreted modulo 256 as UTF-8 bytes) |
| Output | Str | the string represented by the input |
| Program | Type | Value | Error |
[97, 98, 99] bytesToStr | Str | "abc" | |
[75, 195, 182, 108, 110] bytesToStr | Str | "Köln" | |
[230, 151, 165, 230, 156, 172, 232, 170, 158] bytesToStr | Str | "日本語" | |
[0] bytesToStr | Str | "\x00" | |
[256] bytesToStr | Str | "\x00" | |
Converts a string to Unicode code points.
| Type | Value |
| Input | Str | a string |
| Output | Arr<Num...> | the input represented as a sequence of code points |
If the input string contains invalid UTF-8 byte sequences, they will be represented by the Unicode replacement character (code point 65533).
| Program | Type | Value | Error |
"abc" codePoints | Arr<Num...> | [97, 98, 99] | |
"Köln" codePoints | Arr<Num...> | [75, 246, 108, 110] | |
"日本語" codePoints | Arr<Num...> | [26085, 26412, 35486] | |
"\x80" codePoints | Arr<Num...> | [65533] | |
Converts Unicode code points to a string.
| Type | Value |
| Input | Arr<Num...> | a sequence of numbers |
| Output | Str | UTF-8 encoded version of the input |
| Program | Type | Value | Error |
[97, 98, 99] codePointsToStr | Str | "abc" | |
[75, 246, 108, 110] codePointsToStr | Str | "Köln" | |
[26085, 26412, 35486] codePointsToStr | Str | "日本語" | |
[65533] codePointsToStr | Str | "�" | |
Splits a string around whitespace.
| Type | Value |
| Input | Str | a string |
| Output | Arr<Str...> | the result of splitting the string around any kind or amount of white space |
| Program | Type | Value | Error |
" foo bar baz " fields | Arr<Str...> | ["foo", "bar", "baz"] | |
Finds the position of a string within another.
| Type | Value |
| Input | Str | string to search inside |
| needle (param #1) | Str | string to search for |
| Output | Num | offset of first occurrence of needle from the beginning of the input, measured in bytes, or -1 if none |
| Program | Type | Value | Error |
"abc" indexOf("bc") | Num | 1 | |
"abc" indexOf("a") | Num | 0 | |
"abc" indexOf("d") | Num | -1 | |
"Köln" indexOf("l") | Num | 3 | |
Concatenates any number of strings.
| Type | Value |
| Input | Arr<Str...> | an array of strings |
| Output | Str | the concatenation of all the strings in the input |
| Program | Type | Value | Error |
["ab", "cd", "ef"] join | Str | "abcdef" | |
["ab", "cd"] join | Str | "abcd" | |
["ab"] join | Str | "ab" | |
for Any def f Arr<Str...> as [] ok f join | Str | "" | |
Concatenates any number of strings with a custom delimiter.
| Type | Value |
| Input | Arr<Str...> | an array of strings |
| glue (param #1) | Str | delimiter to put between strings |
| Output | Str | the concatenation of all the strings in the input, with the glue in between |
| Program | Type | Value | Error |
["ab", "cd", "ef"] join(";") | Str | "ab;cd;ef" | |
["ab", "", "cd"] join(";") | Str | "ab;;cd" | |
["ab"] join(";") | Str | "ab" | |
for Any def f Arr<Str...> as [] ok f join(";") | Str | "" | |
Right-pads a string.
| Type | Value |
| Input | Str | a string |
| targetLength (param #1) | Num | minimum string length for the output |
| padString (param #2) | Str | string to use as padding to bring the input to the desired length |
| Output | Str | the input followed by as many repetitions of padString as necessary to reach targetLength |
padString is usually one character but can be longer, in which case each repetition starts from the left.
| Program | Type | Value | Error |
"z" padEnd(2, " ") | Str | "z " | |
"z" padEnd(3, " ") | Str | "z " | |
"zzz" padEnd(3, " ") | Str | "zzz" | |
"zzzz" padEnd(3, " ") | Str | "zzzz" | |
"zzzz" padEnd(7, "ab") | Str | "zzzzaba" | |
Left-pads a string.
| Type | Value |
| Input | Str | a string |
| targetLength (param #1) | Num | minimum string length for the output |
| padString (param #2) | Str | string to use as padding to bring the input to the desired length |
| Output | Str | the input following as many repetitions of padString as necessary to reach targetLength |
padString is usually one character but can be longer, in which case each repetition starts from the left.
| Program | Type | Value | Error |
"z" padStart(2, " ") | Str | " z" | |
"z" padStart(3, " ") | Str | " z" | |
"zzz" padStart(3, " ") | Str | "zzz" | |
"zzzz" padStart(3, " ") | Str | "zzzz" | |
"zzzz" padStart(7, "ab") | Str | "abazzzz" | |
Replaces substrings.
| Type | Value |
| Input | Str | a string |
| needle (param #1) | Str | a substring to look for |
| replacement (param #2) | Str | a new string to replace needle with |
| Output | Str | the input with all occurrences of needle replaced with replacement |
More precisely, whenever there are two or more overlapping occurrences of needle in the input, only the first one is replaced.
| Program | Type | Value | Error |
"ababa" replaceAll("b", "c") | Str | "acaca" | |
Replaces a substring.
| Type | Value |
| Input | Str | a string |
| needle (param #1) | Str | a substring to look for |
| replacement (param #2) | Str | a new string to replace needle with |
| Output | Str | the input with the first ocurrence of needle replaced with replacement |
| Program | Type | Value | Error |
"ababa" replaceFirst("b", "c") | Str | "acaba" | |
Checks whether a string starts with a specific substring.
| Type | Value |
| Input | Str | a string |
| needle (param #1) | Str | a prefix to look for |
| Output | Bool | true if the input starts with needle, false otherwise |
| Program | Type | Value | Error |
"abc" startsWith("ab") | Bool | true | |
"abc" startsWith("b") | Bool | false | |
Checks whether a string ends with a specific substring.
| Type | Value |
| Input | Str | a string |
| needle (param #1) | Str | a suffix to look for |
| Output | Bool | true if the input ends with needle, false otherwise |
| Program | Type | Value | Error |
"abc" endsWith("bc") | Bool | true | |
"abc" endsWith("b") | Bool | false | |
Concatenates multiple repetitions of a string.
| Type | Value |
| Input | Str | a string |
| n (param #1) | Num | number of repetitions (will be truncated and min'd to 0) |
| Output | Str | the input, repeated n times |
| Program | Type | Value | Error |
"abc" repeat(3) | Str | "abcabcabc" | |
"abc" repeat(0) | Str | "" | |
"abc" repeat(-1) | Str | "" | |
"abc" repeat(1.6) | Str | "abc" | |
Extracts a substring from a string.
| Type | Value |
| Input | Str | a string |
| start (param #1) | Num | a positive integer |
| Output | Str | the portion of the input that is after offset start |
| Program | Type | Value | Error |
"abc" slice(-4) | Str | "abc" | |
"abc" slice(-3) | Str | "abc" | |
"abc" slice(-2) | Str | "bc" | |
"abc" slice(-1) | Str | "c" | |
"abc" slice(0) | Str | "abc" | |
"abc" slice(1) | Str | "bc" | |
"abc" slice(2) | Str | "c" | |
"abc" slice(3) | Str | "" | |
"abc" slice(4) | Str | "" | |
Extracts a substring from a string.
| Type | Value |
| Input | Str | a string |
| start (param #1) | Num | offset to start after |
| end (param #2) | Num | offset to end before |
| Output | Str | the portion of the input that is after offset start but before offset end |
Negative offsets are counted from the end of the string.
| Program | Type | Value | Error |
"abc" slice(1, 2) | Str | "b" | |
"abc" slice(1, -1) | Str | "b" | |
"abc" slice(-2, -1) | Str | "b" | |
"abc" slice(-1, -2) | Str | "" | |
"abc" slice(2, 1) | Str | "" | |
"abc" slice(-5, -4) | Str | "" | |
"abc" slice(-5, -3) | Str | "" | |
"abc" slice(-5, -2) | Str | "a" | |
"abc" slice(-5, -1) | Str | "ab" | |
"abc" slice(-1, -5) | Str | "" | |
"abc" slice(2, -5) | Str | "" | |
"abc" slice(0, 4) | Str | "abc" | |
"abc" slice(4, 4) | Str | "" | |
Removes whitespace from the start and end of a string.
| Type | Value |
| Input | Str | a string |
| Output | Str | the input, with leading and trailing whitespace removed |
| Program | Type | Value | Error |
" abc " trim | Str | "abc" | |
Removes whitespace from the start of a string.
| Type | Value |
| Input | Str | a string |
| Output | Str | the input, with leading whitespace removed |
| Program | Type | Value | Error |
" abc " trimStart | Str | "abc " | |
Removes whitespace from the end of a string.
| Type | Value |
| Input | Str | a string |
| Output | Str | the input, with trailing whitespace removed |
| Program | Type | Value | Error |
" abc " trimEnd | Str | " abc" | |