Strings
Format, split, join, trim and transform strings.
chomp
chomp(str) → stringRemove trailing newlines from a string.
| Parameter | Type | Description |
|---|---|---|
str | string |
format
format(format, args...) → stringFormat a string using printf-style verbs.
| Parameter | Type | Description |
|---|---|---|
format | string | |
args... | any | Variadic. |
format("hello %s, you are %d", "alice", 30)→ "hello alice, you are 30"
formatlist
formatlist(format, args...) → list(string)Format each element of a list using printf-style verbs.
| Parameter | Type | Description |
|---|---|---|
format | string | |
args... | any | Variadic. |
join
join(separator, list) → stringJoin a list of strings with a separator.
| Parameter | Type | Description |
|---|---|---|
separator | string | |
list | list(string) |
join(", ", ["a", "b", "c"])→ "a, b, c"
lower
lower(str) → stringConvert a string to lowercase.
| Parameter | Type | Description |
|---|---|---|
str | string |
lower("HELLO")→ "hello"
replace
replace(str, old, new) → stringReplace all occurrences of a substring.
| Parameter | Type | Description |
|---|---|---|
str | string | |
old | string | |
new | string |
split
split(separator, str) → list(string)Split a string by a separator.
| Parameter | Type | Description |
|---|---|---|
separator | string | |
str | string |
split(",", "a,b,c")→ ["a", "b", "c"]
strlen
strlen(str) → numberReturn the length of a string in characters.
Use length for collections (lists, maps, tuples). strlen is for strings only.
| Parameter | Type | Description |
|---|---|---|
str | string |
substr
substr(str, offset, length) → stringExtract a substring by offset and length.
| Parameter | Type | Description |
|---|---|---|
str | string | |
offset | number | |
length | number |
title
title(str) → stringConvert a string to title case.
| Parameter | Type | Description |
|---|---|---|
str | string |
title("hello world")→ "Hello World"
trim
trim(str, cutset) → stringRemove leading and trailing characters from a string.
| Parameter | Type | Description |
|---|---|---|
str | string | |
cutset | string | Characters to remove. |
trimprefix
trimprefix(str, prefix) → stringRemove a prefix from the start of a string.
| Parameter | Type | Description |
|---|---|---|
str | string | |
prefix | string |
trimspace
trimspace(str) → stringRemove leading and trailing whitespace from a string.
| Parameter | Type | Description |
|---|---|---|
str | string |
trimsuffix
trimsuffix(str, suffix) → stringRemove a suffix from the end of a string.
| Parameter | Type | Description |
|---|---|---|
str | string | |
suffix | string |
upper
upper(str) → stringConvert a string to uppercase.
| Parameter | Type | Description |
|---|---|---|
str | string |
upper("hello")→ "HELLO"