Text functions
Every function in this family, with its signature and examples. Each example runs as a test of the language. See Language basics for how calls, types, and operators work.
length
Returns the length of the text or list value.
length(text: text) → number
length(list: list<any>) → number
Also callable as receiver.length(…), with the receiver as the first argument.
length("hello")gives5"Notion".length()gives6length([1, 2, 3])gives3
substring
Returns the part of the text from the start index (inclusive) to the optional end index (exclusive).
substring(text: text, start: number, end?: number) → text
Also callable as receiver.substring(…), with the receiver as the first argument.
substring("Notion", 0, 3)gives"Not"substring("Notion", 3)gives"ion"
contains
Returns true if the search text is present in the value.
contains(text: text, search: text) → boolean
Also callable as receiver.contains(…), with the receiver as the first argument.
contains("Notion", "ot")givestrue"Notion".contains("x")givesfalse
test
Returns true if the value matches the regular expression and false otherwise.
test(text: text, pattern: text) → boolean
Also callable as receiver.test(…), with the receiver as the first argument.
test("Notion", "Not")givestruetest("Notion", "\\d")givesfalse
match
Returns every match of the regular expression as a list.
match(text: text, pattern: text) → list<text>
Also callable as receiver.match(…), with the receiver as the first argument.
match("Notion Notion", "Not")gives["Not", "Not"]match("Notion 123 Notion 456", "\\d+")gives["123", "456"]
replace
Replaces the first match of the regular expression with the replacement text.
replace(text: text, pattern: text, replacement: text) → text
Also callable as receiver.replace(…), with the receiver as the first argument.
replace("Notion Notion", "N", "M")gives"Motion Notion"
replaceAll
Replaces every match of the regular expression with the replacement text.
replaceAll(text: text, pattern: text, replacement: text) → text
Also callable as receiver.replaceAll(…), with the receiver as the first argument.
replaceAll("Notion Notion", "N", "M")gives"Motion Motion""Notion 123".replaceAll("\\d", "")gives"Notion "
lower
Converts the text to lowercase.
lower(text: text) → text
Also callable as receiver.lower(…), with the receiver as the first argument.
lower("NOTION")gives"notion""NOTION".lower()gives"notion"
upper
Converts the text to uppercase.
upper(text: text) → text
Also callable as receiver.upper(…), with the receiver as the first argument.
upper("notion")gives"NOTION""notion".upper()gives"NOTION"
repeat
Repeats the text the given number of times.
repeat(text: text, times: number) → text
Also callable as receiver.repeat(…), with the receiver as the first argument.
repeat("0", 4)gives"0000""~=".repeat(10)gives"~=~=~=~=~=~=~=~=~=~="
trim
Removes whitespace from the beginning and end of the text.
trim(text: text) → text
Also callable as receiver.trim(…), with the receiver as the first argument.
trim(" Notion ")gives"Notion"" Notion ".trim()gives"Notion"
format
Converts any value to text; the text conversion for a function or operator that needs text. Numbers print without grouping, dates as ISO-8601 UTC.
format(value: any) → text
Also callable as receiver.format(…), with the receiver as the first argument.
format(prop("qty"))gives"3"format(1234)gives"1234"format(1234567.5)gives"1234567.5"format(true)gives"true"
padStart
Pads the beginning of the value, formatted as text, with the pad text until it reaches the given length.
padStart(value: text, length: number, pad: text) → text
padStart(value: text, length: number, pad: number) → text
padStart(value: number, length: number, pad: text) → text
padStart(value: number, length: number, pad: number) → text
Also callable as receiver.padStart(…), with the receiver as the first argument.
"A".padStart(3, ".")gives"..A"123.padStart(5, 0)gives"00123""hi".padStart(5, "!")gives"!!!hi""hi".padStart(5, "!".length())gives"111hi"
padEnd
Pads the end of the value, formatted as text, with the pad text until it reaches the given length.
padEnd(value: text, length: number, pad: text) → text
padEnd(value: text, length: number, pad: number) → text
padEnd(value: number, length: number, pad: text) → text
padEnd(value: number, length: number, pad: number) → text
Also callable as receiver.padEnd(…), with the receiver as the first argument.
"A".padEnd(3, ".")gives"A.."123.padEnd(5, 0)gives"12300"
isValidIsin
Returns true if the text is a valid ISIN: twelve characters, a two-letter country prefix, and a correct check digit. Empty text is false.
isValidIsin(text: text) → boolean
Also callable as receiver.isValidIsin(…), with the receiver as the first argument.
isValidIsin("US0378331005")givestrue"US0378331006".isValidIsin()givesfalse