Tea
DocsPlaygroundExamplesReferenceCommunity
GitHub

Tea Language

A strongly typed scripting language for native tools.

© 2026 Tea Language.

ContributingCommunityRepository

Language Runtime

Built-ins

Standard Library

std.argsstd.assertstd.audiostd.envstd.fsstd.httpstd.netstd.jsonstd.parsestd.pathstd.processstd.regexstd.stringstd.timestd.url

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 last_index_of(text: String, pattern: String) -> Int

Find the last occurrence of a substring.

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 replace_once(text: String, pattern: String, replacement: String) -> String

Replace the first occurrence 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 split_once(text: String, delimiter: String) -> List[String]?

Split a string into two parts at the first occurrence of a delimiter.

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

Split a string into two parts at the last occurrence of a delimiter.

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

Count non-overlapping occurrences of a substring.

pub def strip_prefix(text: String, prefix: String) -> String?

Remove a prefix when present.

pub def strip_suffix(text: String, suffix: String) -> String?

Remove a suffix when present.

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

Repeat a string count times.

pub def pad_start_with(text: String, width: Int, fill: String) -> String

Pad a string on the left with a fill string until it reaches width.

pub def pad_start(text: String, width: Int) -> String

Pad a string on the left with spaces until it reaches width.

pub def pad_end_with(text: String, width: Int, fill: String) -> String

Pad a string on the right with a fill string until it reaches width.

pub def pad_end(text: String, width: Int) -> String

Pad a string on the right with spaces until it reaches width.