Text Funcers

<

Compares strings lexicographically.

TypeValue
InputStra string
other (param #1)Stranother string
OutputBooltrue if the input appears before other in lexicographical order, false otherwise

Examples

ProgramTypeValueError
"a" <"b"Booltrue
"Ab" <"A"Boolfalse
"cd" <"cd"Boolfalse

>

Compares strings lexicographically.

TypeValue
InputStra string
other (param #1)Stranother string
OutputBooltrue if the input appears after other in lexicographical order, false otherwise

Examples

ProgramTypeValueError
"a" >"b"Boolfalse
"Ab" >"A"Booltrue
"cd" >"cd"Boolfalse

<=

Compares strings lexicographically.

TypeValue
InputStra string
other (param #1)Stranother string
OutputBooltrue if the input appears before other in lexicographical order or is equal to it, false otherwise

Examples

ProgramTypeValueError
"a" <="b"Booltrue
"Ab" <="A"Boolfalse
"cd" <="cd"Booltrue

>=

Compares strings lexicographically.

TypeValue
InputStra string
other (param #1)Stranother string
OutputBooltrue if the input appears after other in lexicographical order or is equal to it, false otherwise

Examples

ProgramTypeValueError
"a" >="b"Boolfalse
"Ab" >="A"Booltrue
"cd" >="cd"Booltrue

+

Concatenates two strings.

TypeValue
InputStra string
b (param #1)Stranother string
OutputStrThe input and b, concatenated.

Examples

ProgramTypeValueError
"ab" +"cd"Str"abcd"
"ab" +""Str"ab"
"" +"cd"Str"cd"

bytes

Converts a string to bytes.

TypeValue
InputStra string
OutputArr<Num...>The UTF-8 bytes representing the string.

Examples

ProgramTypeValueError
"abc" bytesArr<Num...>[97, 98, 99]
"Köln" bytesArr<Num...>[75, 195, 182, 108, 110]
"日本語" bytesArr<Num...>[230, 151, 165, 230, 156, 172, 232, 170, 158]
"\x00" bytesArr<Num...>[0]

bytesToStr

Converts bytes to a string.

TypeValue
InputArr<Num...>an array of numbers (interpreted modulo 256 as UTF-8 bytes)
OutputStrthe string represented by the input

Examples

ProgramTypeValueError
[97, 98, 99] bytesToStrStr"abc"
[75, 195, 182, 108, 110] bytesToStrStr"Köln"
[230, 151, 165, 230, 156, 172, 232, 170, 158] bytesToStrStr"日本語"
[0] bytesToStrStr"\x00"
[256] bytesToStrStr"\x00"

codePoints

Converts a string to Unicode code points.

TypeValue
InputStra string
OutputArr<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).

Examples

ProgramTypeValueError
"abc" codePointsArr<Num...>[97, 98, 99]
"Köln" codePointsArr<Num...>[75, 246, 108, 110]
"日本語" codePointsArr<Num...>[26085, 26412, 35486]
"\x80" codePointsArr<Num...>[65533]

codePointsToStr

Converts Unicode code points to a string.

TypeValue
InputArr<Num...>a sequence of numbers
OutputStrUTF-8 encoded version of the input

Examples

ProgramTypeValueError
[97, 98, 99] codePointsToStrStr"abc"
[75, 246, 108, 110] codePointsToStrStr"Köln"
[26085, 26412, 35486] codePointsToStrStr"日本語"
[65533] codePointsToStrStr"�"

fields

Splits a string around whitespace.

TypeValue
InputStra string
OutputArr<Str...>the result of splitting the string around any kind or amount of white space

Examples

ProgramTypeValueError
" foo bar baz " fieldsArr<Str...>["foo", "bar", "baz"]

indexOf

Finds the position of a string within another.

TypeValue
InputStrstring to search inside
needle (param #1)Strstring to search for
OutputNumoffset of first occurrence of needle from the beginning of the input, measured in bytes, or -1 if none

Examples

ProgramTypeValueError
"abc" indexOf("bc")Num1
"abc" indexOf("a")Num0
"abc" indexOf("d")Num-1
"Köln" indexOf("l")Num3

join

Concatenates any number of strings.

TypeValue
InputArr<Str...>an array of strings
OutputStrthe concatenation of all the strings in the input

Examples

ProgramTypeValueError
["ab", "cd", "ef"] joinStr"abcdef"
["ab", "cd"] joinStr"abcd"
["ab"] joinStr"ab"
for Any def f Arr<Str...> as [] ok f joinStr""

join

Concatenates any number of strings with a custom delimiter.

TypeValue
InputArr<Str...>an array of strings
glue (param #1)Strdelimiter to put between strings
OutputStrthe concatenation of all the strings in the input, with the glue in between

Examples

ProgramTypeValueError
["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""

padEnd

Right-pads a string.

TypeValue
InputStra string
targetLength (param #1)Numminimum string length for the output
padString (param #2)Strstring to use as padding to bring the input to the desired length
OutputStrthe 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.

Examples

ProgramTypeValueError
"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"

padStart

Left-pads a string.

TypeValue
InputStra string
targetLength (param #1)Numminimum string length for the output
padString (param #2)Strstring to use as padding to bring the input to the desired length
OutputStrthe 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.

Examples

ProgramTypeValueError
"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"

replaceAll

Replaces substrings.

TypeValue
InputStra string
needle (param #1)Stra substring to look for
replacement (param #2)Stra new string to replace needle with
OutputStrthe 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.

Examples

ProgramTypeValueError
"ababa" replaceAll("b", "c")Str"acaca"

replaceFirst

Replaces a substring.

TypeValue
InputStra string
needle (param #1)Stra substring to look for
replacement (param #2)Stra new string to replace needle with
OutputStrthe input with the first ocurrence of needle replaced with replacement

Examples

ProgramTypeValueError
"ababa" replaceFirst("b", "c")Str"acaba"

startsWith

Checks whether a string starts with a specific substring.

TypeValue
InputStra string
needle (param #1)Stra prefix to look for
OutputBooltrue if the input starts with needle, false otherwise

Examples

ProgramTypeValueError
"abc" startsWith("ab")Booltrue
"abc" startsWith("b")Boolfalse

endsWith

Checks whether a string ends with a specific substring.

TypeValue
InputStra string
needle (param #1)Stra suffix to look for
OutputBooltrue if the input ends with needle, false otherwise

Examples

ProgramTypeValueError
"abc" endsWith("bc")Booltrue
"abc" endsWith("b")Boolfalse

repeat

Concatenates multiple repetitions of a string.

TypeValue
InputStra string
n (param #1)Numnumber of repetitions (will be truncated and min'd to 0)
OutputStrthe input, repeated n times

Examples

ProgramTypeValueError
"abc" repeat(3)Str"abcabcabc"
"abc" repeat(0)Str""
"abc" repeat(-1)Str""
"abc" repeat(1.6)Str"abc"

slice

Extracts a substring from a string.

TypeValue
InputStra string
start (param #1)Numa positive integer
OutputStrthe portion of the input that is after offset start

Examples

ProgramTypeValueError
"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""

slice

Extracts a substring from a string.

TypeValue
InputStra string
start (param #1)Numoffset to start after
end (param #2)Numoffset to end before
OutputStrthe portion of the input that is after offset start but before offset end

Negative offsets are counted from the end of the string.

Examples

ProgramTypeValueError
"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""

trim

Removes whitespace from the start and end of a string.

TypeValue
InputStra string
OutputStrthe input, with leading and trailing whitespace removed

Examples

ProgramTypeValueError
" abc " trimStr"abc"

trimStart

Removes whitespace from the start of a string.

TypeValue
InputStra string
OutputStrthe input, with leading whitespace removed

Examples

ProgramTypeValueError
" abc " trimStartStr"abc "

trimEnd

Removes whitespace from the end of a string.

TypeValue
InputStra string
OutputStrthe input, with trailing whitespace removed

Examples

ProgramTypeValueError
" abc " trimEndStr" abc"