TRIM function - Amazon Quantum Ledger Database (Amazon QLDB)

TRIM function

Trims a given string by removing the leading and trailing blank spaces or a specified set of characters.

Syntax

TRIM ( [ LEADING | TRAILING | BOTH [ characters ] FROM ] string)

Arguments

LEADING

(Optional) Indicates that the blank spaces or specified characters are to be removed from the beginning of string. If not specified, the default behavior is BOTH.

TRAILING

(Optional) Indicates that the blank spaces or specified characters are to be removed from the end of string. If not specified, the default behavior is BOTH.

BOTH

(Optional) Indicates that both the leading and trailing blank spaces or specified characters are to be removed from the beginning and end of string.

characters

(Optional) The set of characters to remove, specified as a string.

If this parameter is not provided, blank spaces are removed.

string

The field name or expression of data type string that the functions trims.

Return type

string

Examples

TRIM(' foobar ') -- 'foobar' TRIM(' \tfoobar\t ') -- '\tfoobar\t' TRIM(LEADING FROM ' foobar ') -- 'foobar ' TRIM(TRAILING FROM ' foobar ') -- ' foobar' TRIM(BOTH FROM ' foobar ') -- 'foobar' TRIM(BOTH '1' FROM '11foobar11') -- 'foobar' TRIM(BOTH '12' FROM '1112211foobar22211122') -- 'foobar' -- Runnable statements SELECT TRIM(' foobar ') FROM << 0 >> -- "foobar" SELECT TRIM(LEADING FROM ' foobar ') FROM << 0 >> -- "foobar "

Related functions