std/string
String manipulation utilities for searching, transforming, and inspecting strings.
from "std/string" import { strContains, strSplit, strReplace, strTrim, strToLower }Functions
strContains
fn strContains(haystack: &string, needle: &string): boolReturns true if haystack contains needle.
strIndexOf
fn strIndexOf(haystack: &string, needle: &string): i64Returns the index of the first occurrence of needle, or -1 if not found.
strIndexOfFrom
fn strIndexOfFrom(haystack: &string, needle: &string, start: i64): i64Like strIndexOf, but begins searching from byte offset start.
strStartsWith
fn strStartsWith(s: &string, prefix: &string): boolReturns true if s starts with prefix.
strEndsWith
fn strEndsWith(s: &string, suffix: &string): boolReturns true if s ends with suffix.
strToLower
fn strToLower(s: &string): stringReturns a new string with all ASCII characters lowercased.
strToUpper
fn strToUpper(s: &string): stringReturns a new string with all ASCII characters uppercased.
strTrim
fn strTrim(s: &string): stringReturns a new string with leading and trailing whitespace removed.
strTrimStart
fn strTrimStart(s: &string): stringReturns a new string with leading whitespace removed.
strTrimEnd
fn strTrimEnd(s: &string): stringReturns a new string with trailing whitespace removed.
strSplit
fn strSplit(s: &string, delimiter: &string): Vec<string>Splits s by delimiter and returns the parts.
let parts = strSplit(&"a,b,c", &",")
// parts == ["a", "b", "c"]strRepeat
fn strRepeat(s: &string, count: i64): stringReturns s repeated count times.
strReplace
fn strReplace(s: &string, old: &string, new: &string): stringReplaces all occurrences of old with new in s.
charIsWhitespace
fn charIsWhitespace(c: u8): boolReturns true if c is an ASCII whitespace character.
charIsDigit
fn charIsDigit(c: u8): boolReturns true if c is an ASCII digit (0-9).
charIsAlpha
fn charIsAlpha(c: u8): boolReturns true if c is an ASCII letter (a-z, A-Z).
charIsAlphanumeric
fn charIsAlphanumeric(c: u8): boolReturns true if c is an ASCII letter or digit.
trim
fn trim(s: &string): stringAlias for strTrim. Returns a new string with leading and trailing whitespace removed.