TRIM - Amazon Kinesis Data Analytics

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

TRIM

TRIM ( [ [ <trim-specification> ] [ <trim-character> ] FROM ] <trim-source> ) <trim-specification> := LEADING | TRAILING | BOTH <trim-character> := <character-expression> <trim-source> := <character-expression>

TRIM 根据修剪规范(即 LEADING、TRAILING 或 BOTH)的规定,从修剪源字符串的开头和/或结尾删除指定修剪字符的实例。如果指定了 LEADING,则仅删除源字符串开头重复的修剪字符。如果指定了 TRAILING,则仅删除源字符串末尾重复的修剪字符。如果同时指定了 BOTH,或者完全省略了修剪说明符,则将从源字符串的开头和结尾删除重复项。

如果未明确指定修剪字符,则默认为空格字符 ('')。只允许使用一个修剪字符;指定空字符串或长度超过一个字符的字符串会导致异常。

如果任一输入为 null,则返回 null。

示例

函数 结果
TRIM(' Trim front and back ')
'Trim front and back'
TRIM (BOTH FROM ' Trim front and back ')
'Trim front and back'
TRIM (BOTH ' ' FROM ' Trim front and back ')
'Trim front and back'
TRIM (LEADING 'x' FROM 'xxxTrim frontxxx')
'Trim frontxxx'
TRIM (TRAILING 'x' FROM 'xxxTrimxBackxxx')
'xxxTrimxBack'
TRIM (BOTH 'y' FROM 'xxxNo y to trimxxx')
'xxxNo y to trimxxx'