On this page本页内容
$rtrim
¶New in version 4.0.版本4.0中的新功能。
Removes whitespace characters, including null, or the specified characters from the end of a string.
$rtrim
has the following syntax:语法如下所示:
The $rtrim
takes a document with the following fields:
input |
The string to trim. The argument can be any valid expression that resolves to a string. For more information on expressions, see Expressions. |
chars |
The argument can be any valid expression that resolves to a string. The If unspecified, |
$rtrim
removes whitespaces, including the null character, from the end of the input string:
{ $rtrim: { input: " \n good bye \t " } } |
" \n good bye" |
chars
field.
For example, the following trims any g
and e
from the end of the input string. Since the input ends with a whitespace, neither character can be trimmed from the end of the string.
{ $rtrim: { input: "ggggoodbyeeeee ", chars: "ge" } } |
"ggggoodbyeeeee " |
chars
field.
For example, the following trims any space or e
from the end of the input string.
{ $rtrim: { input: " ggggoodbyeeeee ", chars: "e " } } |
" ggggoodby" |
By default, $rtrim
removes the following whitespaces, including the null character:
Unicode | Escape sequence | |
---|---|---|
U+0000 | ‘0’ | Null character |
U+0020 | ‘ ‘ | Space |
U+0009 | ‘t’ | Horizontal tab |
U+000A | ‘n’ | Line feed/new line |
U+000B | ‘v’ | Vertical tab |
U+000C | ‘f’ | Form feed |
U+000D | ‘r’ | Carriage return |
U+00A0 | Non-breaking space | |
U+1680 | Ogham space mark | |
U+2000 | En quad | |
U+2001 | Em quad | |
U+2002 | En space | |
U+2003 | Em space | |
U+2004 | Three-per-em space | |
U+2005 | Four-per-em space | |
U+2006 | Six-per-em space | |
U+2007 | Figure space | |
U+2008 | Punctuation space | |
U+2009 | Thin space | |
U+200A | Hair space |