trim(LEADING | TRAILING | BOTH, {chars}, {str})
Removes leading or trailing characters from a string. If no characters are specified, the function removes blank spaces.
The trim function isn’t supported in Analytics Studio. An error occurs when the function is used in the UI. The function is available using the Query API. For more information, see Query CRM Analytics Data with the Query API.
LEADINGOptional. Specify to remove characters from the beginning of the string.
TRAILINGOptional. Specify to remove characters from the end of the string.
BOTHOptional. Specify to remove characters from both the start and end of the string.
If LEADING, TRAILING, or BOTH aren’t specified, trim() defaults to BOTH.
This example shows all variations of the trim() function for removing the characters “A”, “b”, and “n” from the beginning, end, or both sides of the City field string.
| City | TrimCity | LTrimCity | RTrimCity | BothTrimCity |
|---|---|---|---|---|
| Aberdeen | erdee | erdeen | Aberdee | erdee |
| Abilene | ilene | ilene | Abilene | ilene |
| Akron | kro | kron | Akro | kro |
| Albuquerque | lbuquerque | lbuquerque | Albuquerque | Ibuquerque |
| Alexandria | lexandria | lexandria | Alexandria | lexandria |