Expand description
The string module — 20 functions.
| Function | Signature | Description |
|---|---|---|
string.length | (s: string) -> number | Number of characters |
string.concat | (a: string, b: string) -> string | Concatenate two strings |
string.contains | (haystack: string, needle: string) -> bool | True if needle found |
string.slice | (s: string, start: number, end: number) -> string | Substring [start, end) |
string.trim | (s: string) -> string | Remove leading/trailing WS |
string.split | (s: string, delimiter: string) -> list<string> | Split by delimiter |
string.to_upper | (s: string) -> string | Uppercase |
string.to_lower | (s: string) -> string | Lowercase |
string.starts_with | (s: string, prefix: string) -> bool | Prefix check |
string.ends_with | (s: string, suffix: string) -> bool | Suffix check |
string.replace | (s: string, old: string, new: string) -> string | Replace first occurrence |
string.replace_all | (s: string, old: string, new: string) -> string | Replace all occurrences |
string.pad_start | (s: string, length: number, pad: string) -> string | Left-pad to target length |
string.pad_end | (s: string, length: number, pad: string) -> string | Right-pad to target length |
string.repeat | (s: string, count: number) -> string | Repeat string N times |
string.join | (items: list<string>, separator: string) -> string | Join list with separator |
string.format | (template: string, values: record) -> string | {key} placeholder replacement |
string.from | (value: any) -> string | Any value to string |
string.is_empty | (s: string) -> bool | True if zero length |
string.index_of | (s: string, sub: string) -> number | Index of sub, or -1 |
Structs§
- String
Module - The
stringstdlib module.