String

The 'string' module provides string manipulation functionality

Function Signatures

// Splits a string into an array of substrings using the specified delimiter.
const split = (str: String, delim: String = "") => [String]

// Removes leading and trailing whitespace from a string.
const trim = (str: String) => String

// Converts a string into an array of characters.
const chars = (str: String) => [String]

// Replaces all occurrences of a substring in a string with another substring.
const replaceAll = (str: String, from: String, to: String) => String

// Retrieves the character at the specified index in a string.
const at = (str: String, index: Number) => String | None

// Retrieves the first character of a string.
const first = (str: String) => String

// Retrieves the last character of a string.
const last = (str: String) => String

// Joins the elements of an array into a single string with a specified delimiter.
const join = (list: Array, delim: String = " ") => String

// Checks if a string starts with a specified substring.
const startsWith = (str: String, start: String) => Boolean

// Checks if a string ends with a specified substring.
const endsWith = (str: String, end: String) => Boolean

// Retrieves a substring from a string starting at a specified index with a specified length.
const substring = (str: String, start: Number, length: Number) => String

// Checks if a string contains a specified substring.
const contains = (str: String, substr: String) => Boolean

// Converts a string into an array of wide characters (to handle unicode)
const w_chars = (str: String, width = 2) => Any

Last updated