Reference

String

Constructor

Input A text surrounded by single or double quotes.
Output A string containing the text.

Signature

"Lorem ipsum dolor sit amet": String

Example

"Hello, world!"

Indexing

Input A string and a number representing the index.
Output The character at the specified index.

Signature

String[Number]: String

Example

"hello"[0] // returns "h"

At

Input A string and a number representing the index.
Output The character at the specified index.

Signature

str_at(a: String, b: Number): String

Example

str_at("hello", 1) // returns "e"

First

Input A string.
Output The first character of the string.

Signature

str_first(a: String): String

Example

str_first("hello") // returns "h"

Last

Input A string.
Output The last character of the string.

Signature

str_last(a: String): String

Example

str_last("hello") // returns "o"

Substring

Input A string and two numbers representing the start and end indices.
Output The substring from the start index to the end index.

Signature

str_substring(a: String, b: Number, c: Number): String

Example

str_substring("hello", 1, 4) // returns "ell"

Init

Input A string.
Output A new string without its last character.

Signature

str_init(a: String): String

Example

str_init("hello") // returns "hell"

Rest

Input A string.
Output A new string without its first character.

Signature

str_rest(a: String): String

Example

str_rest("hello") // returns "ello"

Take

Input A string and a number representing the number of characters.
Output The first n characters of the string.

Signature

str_take(a: String, b: Number): String

Example

str_take("hello", 3) // returns "hel"

Drop

Input A string and a number representing the number of characters.
Output A new string without the first n characters.

Signature

str_drop(a: String, b: Number): String

Example

str_drop("hello", 2) // returns "llo"

Concat

Input Two strings.
Output The concatenation of the two strings.

Signature

str_concat(a: String, b: String): String

Example

str_concat("hello", " world") // returns "hello world"

Replace

Input A string, a regex pattern, and a replacement string.
Output A new string with all matches of the regex pattern replaced by the replacement string.

Signature

str_replace(a: String, b: String, c: String): String

Example

str_replace("hello world", "world", "there") // returns "hello there"

Uppercase

Input A string.
Output A new string converted to uppercase.

Signature

str_uppercase(a: String): String

Example

str_uppercase("hello") // returns "HELLO"

Lowercase

Input A string.
Output A new string converted to lowercase.

Signature

str_lowercase(a: String): String

Example

str_lowercase("HELLO") // returns "hello"

Trim

Input A string.
Output A new string with leading and trailing whitespace removed.

Signature

str_trim(a: String): String

Example

str_trim("  hello  ") // returns "hello"

Trim Left

Input A string.
Output A new string with leading whitespace removed.

Signature

str_trimLeft(a: String): String

Example

str_trimLeft("  hello") // returns "hello"

Trim Right

Input A string.
Output A new string with trailing whitespace removed.

Signature

str_trimRight(a: String): String

Example

str_trimRight("hello  ") // returns "hello"

Capitalize

Input A string.
Output A new string with the first character capitalized.

Signature

str_capitalize(a: String): String

Example

str_capitalize("hello") // returns "Hello"

Repeat

Input A string and a number.
Output The string repeated n times.

Signature

str_repeat(a: String, b: Number): String

Example

str_repeat("ab", 3) // returns "ababab"

Remove at

Input A string and a number representing the index.
Output A new string with the character at the specified index removed.

Signature

str_removeAt(a: String, b: Number): String

Example

str_removeAt("hello", 1) // returns "hllo"

Reverse

Input A string.
Output A new string with its characters in reverse order.

Signature

str_reverse(a: String): String

Example

str_reverse("hello") // returns "olleh"

Pad left

Input A string, a number representing the minimum length, and a string to pad with.
Output A new string padded on the left with the specified padding.

Signature

str_padLeft(a: String, b: Number, c: String): String

Example

str_padLeft("42", 5, "0") // returns "00042"

Pad right

Input A string, a number representing the minimum length, and a string to pad with.
Output A new string padded on the right with the specified padding.

Signature

str_padRight(a: String, b: Number, c: String): String

Example

str_padRight("hi", 5, ".") // returns "hi..."

Split

Input A string and a separator string.
Output A list of the string's substrings separated by the separator.

Signature

str_split(a: String, b: String): List

Example

str_split("a,b,c", ",") // returns ["a", "b", "c"]

Lines

Input A string.
Output A list of lines in the string.

Signature

str_lines(a: String): List

Example

str_lines("a\nb\nc") // returns ["a", "b", "c"]

Contains

Input Two strings.
Output True if the first string contains the second string. False otherwise.

Signature

str_contains(a: String, b: String): Boolean

Example

str_contains("hello world", "world") // returns true

Starts with

Input Two strings.
Output True if the first string starts with the second string. False otherwise.

Signature

str_startsWith(a: String, b: String): Boolean

Example

str_startsWith("hello", "hel") // returns true

Ends with

Input Two strings.
Output True if the first string ends with the second string. False otherwise.

Signature

str_endsWith(a: String, b: String): Boolean

Example

str_endsWith("hello", "llo") // returns true

Match

Input A string and a regex pattern.
Output True if the string matches the regex pattern. False otherwise.

Signature

str_match(a: String, b: String): Boolean

Example

str_match("hello123", "[a-z]+[0-9]+") // returns true

Index of

Input Two strings.
Output The index of the first occurrence of the second string in the first string, or -1 if not found.

Signature

str_indexOf(a: String, b: String): Number

Example

str_indexOf("hello", "l") // returns 2

Last Index Of

Input A string and a substring.
Output The index of the last occurrence of the substring, or -1 if not found.

Signature

str_lastIndexOf(a: String, b: String): Number

Example

str_lastIndexOf("hello", "l") // returns 3

Count

Input A string and a substring.
Output The number of occurrences of the substring in the string. If the substring is empty, returns the length of the string plus one (the number of positions where an empty string can be found).

Signature

str_count(a: String, b: String): Number

Example

str_count("banana", "a") // returns 3

Length

Input A string.
Output The length of the string.

Signature

str_length(a: String): Number

Example

str_length("hello") // returns 5

Is empty

Input A string.
Output True if the string is empty. False otherwise.

Signature

str_isEmpty(a: String): Boolean

Example

str_isEmpty("") // returns true

Is not empty

Input A string.
Output True if the string is not empty. False otherwise.

Signature

str_isNotEmpty(a: String): Boolean

Example

str_isNotEmpty("hello") // returns true

Is Blank

Input A string.
Output True if the string is empty or contains only whitespace, false otherwise.

Signature

str_isBlank(a: String): Boolean

Example

str_isBlank("   ") // returns true

Is Uppercase

Input A string.
Output True if the string is all uppercase, false otherwise.

Signature

str_isUppercase(a: String): Boolean

Example

str_isUppercase("HELLO") // returns true

Is Lowercase

Input A string.
Output True if the string is all lowercase, false otherwise.

Signature

str_isLowercase(a: String): Boolean

Example

str_isLowercase("hello") // returns true

Is Alpha

Input A string.
Output True if the string contains only letters, false otherwise.

Signature

str_isAlpha(a: String): Boolean

Example

str_isAlpha("hello") // returns true

Is Numeric

Input A string.
Output True if the string contains only digits, false otherwise.

Signature

str_isNumeric(a: String): Boolean

Example

str_isNumeric("12345") // returns true

Is Alphanumeric

Input A string.
Output True if the string contains only letters and digits, false otherwise.

Signature

str_isAlphaNumeric(a: String): Boolean

Example

str_isAlphaNumeric("hello123") // returns true

Bytes

Input A string.
Output A list of the string's bytes.

Signature

str_bytes(a: String): List

Example

str_bytes("AB") // returns [65, 66]

From Bytes

Input A list of bytes.
Output A string created from the byte list.

Signature

str_fromBytes(a: List): String

Example

str_fromBytes([72, 105]) // returns "Hi"

Compare

Input Two strings.
Output 1 if the first string is bigger than the second. -1 if it is the smaller. 0 if they are equal.

Signature

str_compare(a: String, b: String): Number

Example

str_compare("apple", "banana") // returns -1