String Library
Stof's standard string library ("String").
Common Value Functions
String.toString(val: str): str
Returns this string as it would be printed to the console.
String.or(val: str, ...): unknown
Returns the first non-empty (null or void) argument, just like the Standard Library "or" function.
String Functions
String.len(val: str): int
Return the length of this string.
String.at(val: str, index: int): str
Get a character from this string at a specific index. The functions "at" and "len" together enable iteration with for loops as well.
String.first(val: str): str
Return the first character in the string, or null if the string is empty.
String.last(val: str): str
Return the last character in the string, or null if the string is empty.
String.startsWith(val: str, substr: str): bool
Return true if the string starts with "substr".
String.endsWith(val: str, substr: str): bool
Return true if the string ends with "substr".
String.push(val: str, ...additional: unknown): void
Push additional arguments (turned into strings) to the end of "val".
String.contains(val: str, substr: str): bool
Return true if "val" contains the substring.
String.indexOf(val: str, substr: str): int
Return the index of the first character of "substr" found in "val". If not found, returns -1.
String.replace(val: str, from: str, to: str): str
Replace all instances of a substring in this string, returning a new string.
String.split(val: str, substr: str): vec
Split this string into a vector of strings, separated at every occurrence of "substr".
String.toUpper(val: str): str
Transforms this string to all uppercase letters, returning a new string.
String.toLower(val: str): str
Transforms this string to all lowercase letters, returning a new string.
String.trim(val: str): str
Will trim the whitespace off of the start and end of this string (spaces, newlines, tabs), returning a new string.
String.trimStart(val: str): str
Will trim the whitespace off of the start of this string (spaces, newlines, tabs), returning a new string.
String.trimEnd(val: str): str
Will trim the whitespace off of the end of this string (spaces, newlines, tabs), returning a new string.
String.substring(val: str, start: int, end?: int): str
Returns a substring of "val" from a starting index up to (but not including) an optional ending index. If the ending index is omitted, the resulting substring will be from a starting index to the end of "val" (default end is the length of "val").
Last updated