These functions all operate on string expressions only, and will return an error if used on any other values.
The exception to this rule is toString()
, which also accepts numbers, booleans and temporal values (i.e. Date, Time. LocalTime, DateTime, LocalDateTime or Duration values).
Functions taking a string as input all operate on Unicode characters rather than on a standard char[]
. For example, size(s)
, where s
is a character in the Chinese alphabet, will return 1.
The functions |
When |
See also Section 2.7.7, “String operators”.
Functions:
left()
returns a string containing the specified number of leftmost characters of the original string.
Syntax: left(original, length)
Returns:
A String. |
Arguments:
Name | Description |
---|---|
|
An expression that returns a string. |
|
An expression that returns a positive integer. |
Considerations:
|
|
If |
If |
Query.
RETURN left('hello', 3)
left('hello', 3) |
---|
1 row |
|
Try this query live. none RETURN left('hello', 3)
lTrim()
returns the original string with leading whitespace removed.
Syntax: lTrim(original)
Returns:
A String. |
Arguments:
Name | Description |
---|---|
|
An expression that returns a string. |
Considerations:
|
Query.
RETURN lTrim(' hello')
lTrim(' hello') |
---|
1 row |
|
Try this query live. none RETURN lTrim(' hello')
replace()
returns a string in which all occurrences of a specified string in the original string have been replaced by another (specified)
string.
Syntax: replace(original, search, replace)
Returns:
A String. |
Arguments:
Name | Description |
---|---|
|
An expression that returns a string. |
|
An expression that specifies the string to be replaced in |
|
An expression that specifies the replacement string. |
Considerations:
If any argument is |
If |
Query.
RETURN replace("hello", "l", "w")
replace("hello", "l", "w") |
---|
1 row |
|
Try this query live. none RETURN replace("hello", "l", "w")
reverse()
returns a string in which the order of all characters in the original string have been reversed.
Syntax: reverse(original)
Returns:
A String. |
Arguments:
Name | Description |
---|---|
|
An expression that returns a string. |
Considerations:
|
Query.
RETURN reverse('anagram')
reverse('anagram') |
---|
1 row |
|
Try this query live. none RETURN reverse('anagram')
right()
returns a string containing the specified number of rightmost characters of the original string.
Syntax: right(original, length)
Returns:
A String. |
Arguments:
Name | Description |
---|---|
|
An expression that returns a string. |
|
An expression that returns a positive integer. |
Considerations:
|
|
If |
If |
Query.
RETURN right('hello', 3)
right('hello', 3) |
---|
1 row |
|
Try this query live. none RETURN right('hello', 3)
rTrim()
returns the original string with trailing whitespace removed.
Syntax: rTrim(original)
Returns:
A String. |
Arguments:
Name | Description |
---|---|
|
An expression that returns a string. |
Considerations:
|
Query.
RETURN rTrim('hello ')
rTrim('hello ') |
---|
1 row |
|
Try this query live. none RETURN rTrim('hello ')
split()
returns a list of strings resulting from the splitting of the original string around matches of the given delimiter.
Syntax: split(original, splitDelimiter)
Returns:
A list of Strings. |
Arguments:
Name | Description |
---|---|
|
An expression that returns a string. |
|
The string with which to split |
Considerations:
|
Query.
RETURN split('one,two', ',')
split('one,two', ',') |
---|
1 row |
|
Try this query live. none RETURN split('one,two', ',')
substring()
returns a substring of the original string, beginning with a 0-based index start and length.
Syntax: substring(original, start [, length])
Returns:
A String. |
Arguments:
Name | Description |
---|---|
|
An expression that returns a string. |
|
An expression that returns a positive integer, denoting the position at which the substring will begin. |
|
An expression that returns a positive integer, denoting how many characters of |
Considerations:
|
If |
If |
If either |
If |
If |
Query.
RETURN substring('hello', 1, 3), substring('hello', 2)
substring('hello', 1, 3) | substring('hello', 2) |
---|---|
1 row |
|
|
|
Try this query live. none RETURN substring('hello', 1, 3), substring('hello', 2)
toLower()
returns the original string in lowercase.
Syntax: toLower(original)
Returns:
A String. |
Arguments:
Name | Description |
---|---|
|
An expression that returns a string. |
Considerations:
|
Query.
RETURN toLower('HELLO')
toLower('HELLO') |
---|
1 row |
|
Try this query live. none RETURN toLower('HELLO')
toString()
converts an integer, float or boolean value to a string.
Syntax: toString(expression)
Returns:
A String. |
Arguments:
Name | Description |
---|---|
|
An expression that returns a number, a boolean, or a string. |
Considerations:
|
If |
Query.
RETURN toString(11.5), toString('already a string'), toString(TRUE ), toString(date({ year:1984, month:10, day:11 })) AS dateString, toString(datetime({ year:1984, month:10, day:11, hour:12, minute:31, second:14, millisecond: 341, timezone: 'Europe/Stockholm' })) AS datetimeString, toString(duration({ minutes: 12, seconds: -60 })) AS durationString
toString(11.5) | toString('already a string') | toString(TRUE ) | dateString | datetimeString | durationString |
---|---|---|---|---|---|
1 row |
|||||
|
|
|
|
|
|
Try this query live. none RETURN toString(11.5), toString('already a string'), toString(true), toString(date({year:1984, month:10, day:11})) AS dateString, toString(datetime({year:1984, month:10, day:11, hour:12, minute:31, second:14, millisecond: 341, timezone: 'Europe/Stockholm'})) AS datetimeString, toString(duration({minutes: 12, seconds: -60})) AS durationString
toUpper()
returns the original string in uppercase.
Syntax: toUpper(original)
Returns:
A String. |
Arguments:
Name | Description |
---|---|
|
An expression that returns a string. |
Considerations:
|
Query.
RETURN toUpper('hello')
toUpper('hello') |
---|
1 row |
|
Try this query live. none RETURN toUpper('hello')
trim()
returns the original string with leading and trailing whitespace removed.
Syntax: trim(original)
Returns:
A String. |
Arguments:
Name | Description |
---|---|
|
An expression that returns a string. |
Considerations:
|
Query.
RETURN trim(' hello ')
trim(' hello ') |
---|
1 row |
|
Try this query live. none RETURN trim(' hello ')