String functions
Functions taking a string as input all operate on Unicode characters rather than on a standard char[]. For example, the size() function applied to any Unicode character will return 1, even if the character does not fit in the 16 bits of one char.
|
The functions |
|
When |
See also String operators.
Functions:
left()
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 |
RETURN left('hello', 3)
| left('hello', 3) |
|---|
|
1 row |
ltrim()
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:
|
RETURN lTrim(' hello')
| lTrim(' hello') |
|---|
|
1 row |
replace()
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 |
RETURN replace("hello", "l", "w")
| replace("hello", "l", "w") |
|---|
|
1 row |
reverse()
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:
|
RETURN reverse('anagram')
| reverse('anagram') |
|---|
|
1 row |
right()
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 |
RETURN right('hello', 3)
| right('hello', 3) |
|---|
|
1 row |
rtrim()
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:
|
RETURN rTrim('hello ')
| rTrim('hello ') |
|---|
|
1 row |
split()
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:
|
RETURN split('one,two', ',')
| split('one,two', ',') |
|---|
|
1 row |
substring()
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 |
RETURN substring('hello', 1, 3), substring('hello', 2)
| substring('hello', 1, 3) | substring('hello', 2) |
|---|---|
|
|
1 row |
|
toLower()
toLower() returns the original string in lowercase.
Syntax: toLower(original)
Returns:
A String. |
Arguments:
| Name | Description |
|---|---|
|
An expression that returns a string. |
Considerations:
|
RETURN toLower('HELLO')
| toLower('HELLO') |
|---|
|
1 row |
toString()
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 |
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 |
|||||
toUpper()
toUpper() returns the original string in uppercase.
Syntax: toUpper(original)
Returns:
A String. |
Arguments:
| Name | Description |
|---|---|
|
An expression that returns a string. |
Considerations:
|
RETURN toUpper('hello')
| toUpper('hello') |
|---|
|
1 row |
trim()
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:
|
RETURN trim(' hello ')
| trim(' hello ') |
|---|
|
1 row |