The TRIM function takes a string and removes any leading and trailing whitespace from it.

This function takes a single string as input. It outputs the given string sans any leading or trailing whitespace.


TRIM(base_string) -> trimmed_string



base_string (type: string)
Any string.

Return Values

trimmed_string (type: string)
The input string but with any leading or trailing whitespace removed.


The following example takes the string " Hello, world!    " and trims the whitespace at the beginning and end; that is, the space at the beginning (before "Hello,") and the four spaces at the end are all not present in the output. Note that the space in between "Hello," and "world!" remains; the TRIM function only removes the whitespace from the beginning and end of a string:
TRIM(" Hello, world!    ") -> "Hello, world!"

The following example further demonstrates that TRIM only removes whitespace from the beginning and end of a string. The input string has five spaces between "Hello," and "world!", and TRIM removes none of them:

TRIM("Hello,     world!") -> "Hello,     world!"



Was this article helpful?

0 out of 0 found this helpful