TRIM
removes the trailing, leading, and consecutive spaces in a string.
Function category: Text​
TRIM(arg1)
Arguments | Description |
| A string. |
If we receive the following data that is padded by spaces:
{"data":{"product_reviews": {"review_1": " Product was acceptable, a 6/10.","review_2": " Product was ok, needs improving. "}}
If we want to strip the initial space from the first review, use the following function.
# Remove initial spaceTRIM(data.product_review.review_1)​# returns "Product was acceptable, a 6/10."
We can also reduce any consecutive spaces to a single space. To remove any additional spaces in the second review, use the following function.
# Remove consecutive spacesTRIM(data.product_review.review_2)​# Returns "Product was ok, needs improving."