Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.
Dan Gorman edited this page Nov 29, 2018 · 2 revisions

The TRIM Function

Function Group: Text

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

Syntax

TRIM(arg1)

  • arg1 is a string

Uses

If we receive some data that is padded by spaces, like that shown below:

{  
   "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 just use TRIM:

TRIM(data.product_review.review_1)

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

Other examples

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) => "I thought the product was good, but could use improvement."

Clone this wiki locally