Skip to main content

String

String is a data type which represents text content (list of characters, words). It's defined by wrapping characters using single quotes ' or using double quotes ".

All examples below are valid:

'valid string double quote';
'valid string single quote';

Operators

String operators

OperatorDescriptionExample
+Concatenation of stringsa + b

Comparison operators

OperatorDescriptionExample
==Equalitya == b
!=Inequalitya != b

Functions

len

Accepts a string and returns number of characters within it.

Syntax

len('string'); // 6

upper

Accepts a string and returns the upper-case version of it.

Syntax

upper('string'); // "STRING"

lower

Accepts a string and returns the lower-case version of it.

Syntax

lower('StrInG'); // "string"

startsWith

Accepts two arguments, returns true if string starts with the specified value.

Syntax

startsWith('Saturday night plans', 'Sat'); // true
startsWith('Saturday night plans', 'Sun'); // false

endsWith

Accepts two arguments, returns true if string ends with the specified value.

Syntax

endsWith('Saturday night plans', 'plans'); // true
endsWith('Saturday night plans', 'night'); // false

contains

Accepts two arguments, returns true if string contains the specified value.

Syntax

contains('Saturday night plans', 'night'); // true
contains('Saturday night plans', 'urday'); // true
contains('Saturday night plans', 'Sunday'); // false

matches

Accepts two argument, returns true if string matches the regular expression.

Syntax

matches('12345', '^d+$'); // true
matches('1234a', '^d+$'); // false

extract

Accepts two arguments, return an array of captured groups from regular expression.

Syntax

extract('2022-02-01', '(d{4})-(d{2})-(d{2})'); // ["2022-02-01", "2022", "02", "01"]
extract('foo.bar', '(w+).(w+)'); // ["foo.bar", "foo", "bar"]

string

Accepts one argument, tries to convert variable to string, throws an error on failure

string(20); // "20"
string(true); // "true"