适用范围: NoSQL
返回移除前导和尾随空格或自定义字符后的字符串表达式。
语法
TRIM(<string_expr_1> [, <string_expr_2>])
参数
| 说明 | |
|---|---|
string_expr_1 | 
一个字符串表达式。 | 
string_expr_2(可选) | 
一个可选的字符串表达式,其中包含要从 string_expr_1 中剪裁的字符串。 如果未指定,则默认为剪裁空格。 | 
返回类型
返回一个字符串表达式。
示例
此示例演示了剪裁字符串表达式的各种方法。
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"
  }
]
注解
- 此函数不使用索引。