Strings
Functions for creating, transforming, searching, and inspecting strings.
concat
Variadic signature
concat(src...)
concat concatenates values using their string representations. With one List argument, concatenates its elements. None contributes no text; nested lists are not flattened.
- Parameters
srcAny, repeatedValues to concatenate, or a single List of values.
- Signature
- Variadic
- Returns
StringA string value.
contains
2-parameter signature
contains(text, search)
contains reports whether text contains search.
- Parameters
textStringThe source string.searchStringThe literal string to match.
- Returns
BooleanWhether the literal string matches.
ends_with
2-parameter signature
ends_with(text, suffix)
ends_with reports whether text ends with suffix.
- Parameters
textStringThe source string.suffixStringThe literal string to match.
- Returns
BooleanWhether the literal string matches.
find_first
2-parameter signature
find_first(str, search)
find_first returns the position of the first occurrence of the string search inside the string text. Positions start at 0.
- Parameters
strStringThe source string.searchStringThe string to seek.
- Returns
IntThe character position of the match. If search is not contained in text, -1 is returned. If search is empty, start is returned.
3-parameter signature
find_first(str, search, start)
find_first returns the position of the first occurrence of the string search inside the string text. Positions start at 0.
- Parameters
strStringThe source string.searchStringThe string to seek.startIntLimit the search to a subset of the text, beginning at start.
- Returns
IntThe character position of the match. If search is not contained in text, -1 is returned. If search is empty, start is returned.
4-parameter signature
find_first(str, search, start, end)
find_first returns the position of the first occurrence of the string search inside the string text. Positions start at 0.
- Parameters
strStringThe source string.searchStringThe string to seek.startIntLimit the search to a subset of the text, beginning at start.endIntLimit the search to a subset of the text, ending before end.
- Returns
IntThe character position of the match. If search is not contained in text, -1 is returned. If search is empty, start is returned.
find_last
2-parameter signature
find_last(src, search)
find_last returns the position of the last occurrence of the string search inside the string text. Positions start at 0.
- Parameters
srcStringThe source string.searchStringThe string to seek.
- Returns
IntThe character position of the match. If search is not contained in text, -1 is returned. If search is empty, end is returned.
3-parameter signature
find_last(src, search, start)
find_last returns the position of the last occurrence of the string search inside the string text. Positions start at 0.
- Parameters
srcStringThe source string.searchStringThe string to seek.startIntLimit the search to a subset of the text, beginning at start.
- Returns
IntThe character position of the match. If search is not contained in text, -1 is returned. If search is empty, end is returned.
4-parameter signature
find_last(src, search, start, end)
find_last returns the position of the last occurrence of the string search inside the string text. Positions start at 0.
- Parameters
srcStringThe source string.searchStringThe string to seek.startIntLimit the search to a subset of the text, beginning at start.endIntLimit the search to a subset of the text, ending before end.
- Returns
IntThe character position of the match. If search is not contained in text, -1 is returned. If search is empty, end is returned.
fmt
Variadic signature
fmt(template, values...)
fmt substitutes values using either automatic {} placeholders or zero-based {n} indexes. Modes cannot be mixed. Repeated indexes are allowed. Escape literal braces with {{ and }}. Every supplied value must be referenced.
- Parameters
templateStringThe format string. Indexes contain decimal digits only.valuesAny, repeatedValues substituted using their string representations.
- Signature
- Variadic
- Returns
StringThe formatted string. Malformed braces, missing values, and unused values are errors.
join
2-parameter signature
join(values, separator)
join concatenates a list of strings with one separator between adjacent elements, preserving empty strings.
- Parameters
valuesString[]The strings to join in iteration order. Nested lists and non-strings are invalid.separatorStringThe literal separator.
- Returns
StringThe joined string, or an empty string for an empty list.
left
2-parameter signature
left(str, length)
left returns the leftmost characters of the string value by index.
- Parameters
strStringThe source string.lengthIntNon-negative rune count, clamped to the string length.
- Returns
StringThe leftmost characters of the string value by index.
like
2-parameter signature
like(str, search)
like matches the whole string using glob syntax: * matches any sequence, ? matches one rune, and character classes and alternatives are supported. Percent and underscore are literal.
- Parameters
strStringThe string to search in.searchStringA search pattern that can contain the wildcard characters.
- Returns
BooleanWhether the whole string matches the pattern.
3-parameter signature
like(str, search, caseInsensitive)
like matches the whole string using glob syntax: * matches any sequence, ? matches one rune, and character classes and alternatives are supported. Percent and underscore are literal.
- Parameters
strStringThe string to search in.searchStringA search pattern that can contain the wildcard characters.caseInsensitiveBooleanIf set to true, the matching will be case-insensitive. The default is false.
- Returns
BooleanWhether the whole string matches the pattern.
lower
1-parameter signature
lower(str)
lower converts strings to their lower-case counterparts. All other characters are returned unchanged.
- Parameters
strStringThe source string.
- Returns
StringThe string in lower case.
ltrim
1-parameter signature
ltrim(str)
ltrim returns the string value with whitespace stripped from the start only.
- Parameters
strStringThe string.
- Returns
StringThe string without chars at the left-hand side.
2-parameter signature
ltrim(str, chars)
ltrim returns the string value with whitespace stripped from the start only.
- Parameters
strStringThe string.charsStringLiteral rune cutset. An empty cutset leaves the string unchanged. Omit to trim Unicode whitespace.
- Returns
StringThe string without chars at the left-hand side.
regex_find
2-parameter signature
regex_find(text, pattern)
regex_find finds the first match of a Go regular expression. Use inline flags such as (?i). Captures exclude the full match, preserve declaration order, and use empty strings for unmatched groups. Duplicate named capture groups are invalid, even when no match exists.
- Parameters
textStringThe source string.patternStringThe Go regular expression.
- Returns
Object | NoneAn object with match (String), groups (String[]), and named (Object), or None when no match exists.
regex_find_all
2-parameter signature
regex_find_all(text, pattern)
regex_find_all finds non-overlapping matches in source order using Go regular expression semantics. Empty matches adjacent to a preceding match are ignored. Use inline flags such as (?i). Capture fields follow regex_find. Duplicate named capture groups are invalid, even when no match exists.
- Parameters
textStringThe source string.patternStringThe Go regular expression.
- Returns
Object[]Objects with match (String), groups (String[]), and named (Object). No matches returns an empty array.
regex_replace
3-parameter signature
regex_replace(text, pattern, replacement)
regex_replace replaces all non-overlapping matches of a Go regular expression. Use inline flags such as (?i).
- Parameters
textStringThe source string.patternStringThe Go regular expression.replacementStringGo replacement template: $1 and ${name} expand captures, and $$ inserts a literal dollar sign.
- Returns
StringThe string with matches replaced.
regex_split
2-parameter signature
regex_split(text, pattern)
regex_split splits text at matches of a Go regular expression. Use inline flags such as (?i). Empty matches follow Go regexp.Split semantics.
- Parameters
textStringThe source string.patternStringThe separator expression.
- Returns
String[]All pieces between matches.
3-parameter signature
regex_split(text, pattern, limit)
regex_split splits text at matches of a Go regular expression. Use inline flags such as (?i). Empty matches follow Go regexp.Split semantics.
- Parameters
textStringThe source string.patternStringThe separator expression.limitIntNon-negative maximum result count. Zero returns an empty array; positive limits preserve the unsplit remainder.
- Returns
String[]The pieces between matches.
regex_test
2-parameter signature
regex_test(text, pattern)
regex_test reports whether a Go regular expression matches any part of text. Use inline flags such as (?i).
- Parameters
textStringThe source string.patternStringThe Go regular expression.
- Returns
BooleanWhether a match exists.
repeat
2-parameter signature
repeat(text, count)
repeat concatenates count copies of text.
- Parameters
textStringThe string to repeat.countIntNon-negative repetition count that fits in an Int on the host. The result must not exceed 64 MiB (67108864 UTF-8 bytes), including when count is one.
- Returns
StringThe repeated string. Zero count or empty text returns an empty string for a valid count. Oversized results return an argument error that ON ERROR can catch.
replace
3-parameter signature
replace(str, search, replace)
replace replaces literal, non-overlapping occurrences. An empty search matches before each rune and at the end; replacement text is literal.
- Parameters
strStringThe string to modifysearchStringThe string representing a search patternreplaceStringThe string representing a replace value
- Returns
StringReturns a string with replace substring.
4-parameter signature
replace(str, search, replace, limit)
replace replaces literal, non-overlapping occurrences. An empty search matches before each rune and at the end; replacement text is literal.
- Parameters
strStringThe string to modifysearchStringThe string representing a search patternreplaceStringThe string representing a replace valuelimitIntNon-negative maximum replacements. Zero leaves text unchanged; omitted means unlimited.
- Returns
StringReturns a string with replace substring.
right
2-parameter signature
right(str, length)
right returns the rightmost characters of the string value.
- Parameters
strStringThe source string.lengthIntNon-negative rune count, clamped to the string length.
- Returns
StringThe rightmost characters of the string value.
rtrim
1-parameter signature
rtrim(str)
rtrim returns the string value with whitespace stripped from the end only.
- Parameters
strStringThe string.
- Returns
StringThe string without chars at the right-hand side.
2-parameter signature
rtrim(str, chars)
rtrim returns the string value with whitespace stripped from the end only.
- Parameters
strStringThe string.charsStringLiteral rune cutset. An empty cutset leaves the string unchanged. Omit to trim Unicode whitespace.
- Returns
StringThe string without chars at the right-hand side.
split
2-parameter signature
split(str, separator)
split splits the given string value into a list of strings, using the separator.
- Parameters
strStringThe string to split.separatorStringThe separator.
- Returns
String[]arrayList of strings.
3-parameter signature
split(str, separator, limit)
split splits the given string value into a list of strings, using the separator.
- Parameters
strStringThe string to split.separatorStringThe separator.limitIntNon-negative maximum result count. Zero returns an empty array; positive limits preserve the unsplit remainder. If no limit is given, the number of splits returned is not bounded.
- Returns
String[]arrayList of strings.
starts_with
2-parameter signature
starts_with(text, prefix)
starts_with reports whether text begins with prefix.
- Parameters
textStringThe source string.prefixStringThe literal string to match.
- Returns
BooleanWhether the literal string matches.
substring
2-parameter signature
substring(str, offset)
substring returns a substring of value.
- Parameters
strStringThe source string.offsetIntZero-based rune offset. Negative or out-of-range offsets return an empty string.
- Returns
StringA substring of value.
3-parameter signature
substring(str, offset, length)
substring returns a substring of value.
- Parameters
strStringThe source string.offsetIntZero-based rune offset. Negative or out-of-range offsets return an empty string.lengthIntNon-negative maximum rune count; omitted means the rest of the string.
- Returns
StringA substring of value.
trim
1-parameter signature
trim(str)
trim returns the string value with whitespace stripped from the start and/or end.
- Parameters
strStringThe string.
- Returns
StringThe string without chars on both sides.
2-parameter signature
trim(str, chars)
trim returns the string value with whitespace stripped from the start and/or end.
- Parameters
strStringThe string.charsStringLiteral rune cutset. An empty cutset leaves the string unchanged. Omit to trim Unicode whitespace.
- Returns
StringThe string without chars on both sides.
upper
1-parameter signature
upper(str)
upper converts strings to their upper-case counterparts. All other characters are returned unchanged.
- Parameters
strStringThe source string.
- Returns
StringThe string in upper case.