String functions

Search, split, join, reshape, and slice text.

FunctionDescription
[chars(s: utf8) → [utf8]](functionfnchars)The characters of a string as a list of one-character strings.
concat(a: utf8, b: utf8) → utf8Concatenate two strings into one.
contains(s: utf8, needle: utf8) → boolWhether a string contains a substring.
ends_with(s: utf8, suffix: utf8) → boolWhether a string ends with a suffix.
format(template: utf8) → utf8Substitute trailing arguments into a template's {} placeholders ({{/}} are literal braces).
format_unit(value: i64, type: utf8, unit: utf8) → utf8Render a base-unit value in a chosen literal unit, looking the factor up from a unit type by name — the inverse of literal-unit resolution, so it stays correct if the type's @unit factor changes.
format_unit_value(value: i64, factor: i64, unit: utf8) → utf8Render a number in a unit given its factor explicitly — the primitive behind format_unit for callers that already hold the factor.
[join(parts: [utf8], sep: utf8) → utf8](functionfnjoin)Join a list of strings into one, inserting a separator between each.
pad_end(s: utf8, width: i64, pad: utf8) → utf8Right-pad a string with a fill pattern until it is width characters long.
pad_start(s: utf8, width: i64, pad: utf8) → utf8Left-pad a string with a fill pattern until it is width characters long.
repeat(s: utf8, n: i64) → utf8A string repeated n times (empty for n <= 0).
replace(s: utf8, old: utf8, new: utf8) → utf8Replace every occurrence of a substring with another.
[split(s: utf8, sep: utf8) → [utf8]](functionfnsplit)Split a string on every occurrence of a separator into a list of pieces.
starts_with(s: utf8, prefix: utf8) → boolWhether a string begins with a prefix.
to_lower(s: utf8) → utf8Lowercase every character of a string.
to_upper(s: utf8) → utf8Uppercase every character of a string.
trim(s: utf8) → utf8Remove leading and trailing whitespace from a string.