String
String data type is used to represent textual data — such as sequences of characters or words. Strings can be defined by enclosing the text in either single quotes (‘) or double quotes (“).
Template strings use backticks and support interpolation with ${}.
The following examples are all valid:
"valid string double quote";
'valid string single quote';
`valid string with interpolation ${customer.firstName}`;String Slicing
You can extract a substring using slice notation [start:end], where the character at the start index is included and the character at the end index is excluded.
"hello"[1:3] // "el"
"hello"[0:2] // "he"Operators
Concatenation: a + b
Equality: a == b
Inequality: a != b
Functions
len
Returns the total number of characters it contains.
len('hello'); // 5upper
Converts a given string to its uppercase form.
upper('hello'); // "HELLO"lower
Converts a given string to its lowercase form.
lower('HeLLo'); // "hello"trim
Removes leading and trailing whitespace from a string.
trim(' hello '); // "hello"startsWith
Takes two inputs and returns true if the first string begins with the second value.
startsWith('Hello John', 'Hello'); // true
startsWith('Hello John', 'Doe'); // falseendsWith
Returns true if the first string ends with the second value provided.
endsWith('Hello John', 'John'); // true
endsWith('Hello John', 'Hello'); // falsecontains
Checks whether the first string includes the second value and returns true if it does.
contains('Hello John', 'ello'); // true
contains('Hello John', 'John'); // true
contains('Hello John', 'Doe'); // falsematches
Evaluates whether the input string satisfies a given regular expression pattern and returns true if it matches.
matches('12345', '^\d+$'); // true
matches('1234a', '^\d+$'); // falseextract
Uses a regular expression to return an array containing the captured groups from the input string.
extract('2025-06-01', '(\d{4})-(\d{2})-(\d{2})'); // ["2025-06-01", "2025", "06", "01"]
extract('foo.bar', '(\w+)\.(\w+)'); // ["foo.bar", "foo", "bar"]split
Splits a string into an array of substrings using a delimiter.
split('a,b,c', ','); // ["a", "b", "c"]
split('hello world', ' '); // ["hello", "world"]fuzzyMatch
Performs a fuzzy (approximate) string comparison between two strings. Returns a score between 0 and 1, where 1 is an exact match.
fuzzyMatch('hello', 'helo'); // 0.8 (approximate)
fuzzyMatch('apple', 'orange'); // low scorestring
Convert the input into a string format; throws an error if the conversion fails.
string(20); // "20"
string(true); // "true"