Skip to main content

Module string

Module string 

Source
Expand description

The string module — 20 functions.

FunctionSignatureDescription
string.length(s: string) -> numberNumber of characters
string.concat(a: string, b: string) -> stringConcatenate two strings
string.contains(haystack: string, needle: string) -> boolTrue if needle found
string.slice(s: string, start: number, end: number) -> stringSubstring [start, end)
string.trim(s: string) -> stringRemove leading/trailing WS
string.split(s: string, delimiter: string) -> list<string>Split by delimiter
string.to_upper(s: string) -> stringUppercase
string.to_lower(s: string) -> stringLowercase
string.starts_with(s: string, prefix: string) -> boolPrefix check
string.ends_with(s: string, suffix: string) -> boolSuffix check
string.replace(s: string, old: string, new: string) -> stringReplace first occurrence
string.replace_all(s: string, old: string, new: string) -> stringReplace all occurrences
string.pad_start(s: string, length: number, pad: string) -> stringLeft-pad to target length
string.pad_end(s: string, length: number, pad: string) -> stringRight-pad to target length
string.repeat(s: string, count: number) -> stringRepeat string N times
string.join(items: list<string>, separator: string) -> stringJoin list with separator
string.format(template: string, values: record) -> string{key} placeholder replacement
string.from(value: any) -> stringAny value to string
string.is_empty(s: string) -> boolTrue if zero length
string.index_of(s: string, sub: string) -> numberIndex of sub, or -1

Structs§

StringModule
The string stdlib module.