This repository has been archived by the owner on Oct 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
TRIM
Dan Gorman edited this page Nov 29, 2018
·
2 revisions
TRIM
removes the trailing, leading, and consecutive spaces in a string.
TRIM(arg1)
-
arg1
is a string
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."
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."