TRIM( ) function
Returns a string with trailing spaces removed from the input string.
Syntax
TRIM(string)
Parameters
Name | Type | Description |
---|---|---|
string | character | The value to remove trailing spaces from. |
Output
Character.
Examples
Basic examples
Note that in both examples the leading spaces and spaces between words are not removed by the TRIM( ) function.
Returns " Vancouver":
TRIM(" Vancouver ")
Returns " New York":
TRIM(" New York")
Advanced examples
Removing non-breaking spaces
Non-breaking spaces are not removed by the TRIM( ) function.
If you need to remove trailing non-breaking spaces, create a computed field using the following expression:
DEFINE FIELD Description_cleaned COMPUTED TRIM(REPLACE(Description, CHR(160), CHR(32)))
The REPLACE( ) function replaces any non-breaking spaces with regular spaces, and then TRIM( ) removes any trailing regular spaces.
Remarks
How it works
The TRIM( ) function removes trailing spaces only. Spaces inside the string, and leading spaces, are not removed.
Related functions
TRIM( ) is related to the LTRIM( ) function, which removes any leading spaces from a string, and to the ALLTRIM( ) function, which removes both leading and trailing spaces.