Standard Library

std.string

String manipulation utilities for common text operations.

Exported functions

pub def index_of(text: String, pattern: String) -> Int

Find the first occurrence of a substring.

pub def contains(text: String, pattern: String) -> Bool

Return true when the string contains a substring.

pub def split(text: String, delimiter: String) -> List[String]

Split a string by a delimiter.

pub def starts_with(text: String, prefix: String) -> Bool

Check if a string starts with a given prefix.

pub def ends_with(text: String, suffix: String) -> Bool

Check if a string ends with a given suffix.

pub def trim_start(text: String) -> String

Trim whitespace from the start of a string.

pub def trim_end(text: String) -> String

Trim whitespace from the end of a string.

pub def trim(text: String) -> String

Trim whitespace from both ends of a string.

pub def reverse(text: String) -> String

Reverse a string.

pub def replace(text: String, pattern: String, replacement: String) -> String

Replace all occurrences of a substring with another string.

pub def to_lower(text: String) -> String

Convert a string to lowercase.

pub def to_upper(text: String) -> String

Convert a string to uppercase.

pub def join(parts: List[String], separator: String) -> String

Join a list of strings with a separator.

pub def lines(text: String) -> List[String]

Split text into lines, trimming a trailing "\r" from each line and dropping the final empty line produced by a trailing newline.

pub def repeat(text: String, count: Int) -> String

Repeat a string count times.