Rediger

Del via


TRIM (NoSQL query)

APPLIES TO: NoSQL

Returns a string expression after it removes leading and trailing whitespace or custom characters.

Syntax

TRIM(<string_expr_1> [, <string_expr_2>])

Arguments

Description
string_expr_1 A string expression.
string_expr_2 (Optional) An optional string expression with a string to trim from string_expr_1. If not specified, the default is to trim whitespace.

Return types

Returns a string expression.

Examples

This example illustrates various ways to trim a string expression.

SELECT VALUE {
    trimPrefix: TRIM("   AdventureWorks"),
    trimSuffix: TRIM("AdventureWorks   "),
    trimWhitespace: TRIM("   AdventureWorks   "),
    trimWrongCharacter: TRIM("---AdventureWorks---"),
    trimUnderscores: TRIM("___AdventureWorks___", "_"),
    trimHyphens: TRIM("---AdventureWorks---", "-"),
    trimSubsetCharacters: TRIM("-- AdventureWorks --", "-"),
    trimMultipleCharacters: TRIM("-_-AdventureWorks-_-", "-_")
}
[
  {
    "trimPrefix": "AdventureWorks",
    "trimSuffix": "AdventureWorks",
    "trimWhitespace": "AdventureWorks",
    "trimWrongCharacter": "---AdventureWorks---",
    "trimUnderscores": "AdventureWorks",
    "trimHyphens": "AdventureWorks",
    "trimSubsetCharacters": " AdventureWorks ",
    "trimMultipleCharacters": "AdventureWorks"
  }
]

Remarks

  • This function doesn't use the index.