system.string
The system.string module provides string manipulation functions.
Import
import system.string as str;
⚠️ Note
Always use an alias when importing system.string since string is a reserved keyword.
Functions
Case Conversion
uppercase(s)- Convert to uppercaselowercase(s)- Convert to lowercase
Search & Test
length(s)- String lengthcontains(s, substr)- Check if contains substringstartswith(s, prefix)- Check prefixendswith(s, suffix)- Check suffixindexof(s, substr)- Find substring position
Modification
substring(s, start, end)- Extract substringreplace(s, old, new)- Replace occurrencestrim(s)- Remove whitespacesplit(s, delim)- Split into arrayjoin(arr, delim)- Join array into string
Example
import system.string as str;
import system.io as io;
let s = " Hello, World! ";
io.out.println(str.trim(s)); // "Hello, World!"
io.out.println(str.uppercase(s)); // " HELLO, WORLD! "
io.out.println(str.length(str.trim(s))); // 13
See the full API reference for more details.