TRIM

TRIM removes the trailing, leading, and consecutive spaces in a string.

Function category: Text

Syntax

TRIM(arg1)

Arguments

Description

arg1

A string.

Examples

Example 1: Trim initial space from strings

If we receive the following data that is padded by spaces:

{
"data":{
"product_reviews": {
"review_1": " For me the product was acceptable, a 6/10.",
"review_2": " I thought the product was good, but could use improvement. "
}
}

If we want to strip the initial space from the first review, we can use TRIM:

TRIM(data.product_review.review_1)

This returns the following:

"For me the product was acceptable, a 6/10."

Example 2: Reduce multiple spaces to single spaces

TRIM will also reduce any consecutive spaces to a single space. To remove any additional spaces in "review_2", we can use TRIM:

TRIM(data.product_review.review_2)

This results in the following:

"I thought the product was good, but could use improvement."