TRIM
Returns the string without leading or trailing occurrences of the specified remove string. If remove string is omitted, spaces are removed.
The Analyze function automatically trims both leading and trailing spaces.
Analyze Syntax
func.trim(str)
Analyze Examples
func.trim(' plaidcloud ')
+--------------------------------+
| func.trim(' plaidcloud ') |
+--------------------------------+
| 'plaidcloud' |
+--------------------------------+
SQL Syntax
TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM ] str)
SQL Examples
Please note that ALL the examples in this section will return the string 'databend'.
The following example removes the leading and trailing string 'xxx' from the string 'xxxdatabendxxx':
SELECT TRIM(BOTH 'xxx' FROM 'xxxdatabendxxx');
The following example removes the leading string 'xxx' from the string 'xxxdatabend':
SELECT TRIM(LEADING 'xxx' FROM 'xxxdatabend' );
The following example removes the trailing string 'xxx' from the string 'databendxxx':
SELECT TRIM(TRAILING 'xxx' FROM 'databendxxx' );
If no remove string is specified, the function removes all leading and trailing spaces. The following examples remove the leading and/or trailing spaces:
SELECT TRIM(' databend ');
SELECT TRIM(' databend');
SELECT TRIM('databend ');
Last modified March 27, 2024 at 3:17 PM EST: adding analyze syntax and examples placeholders for stings (4c6f489)