Add trim/0, ltrim/0 and rtrim/0 that trims leading and trailing whitespace (#3056)
This commit is contained in:
1 parent
81f4f883ac
commit
be437ec049
7 files changed
+144
No files matched your search
@@ -1334,6 +1334,26 @@ split("")
|
||||
"xababababax"
|
||||
[1,7,[1,3,5,7]]
|
||||
|
||||
# trim
|
||||
# \u000b is vertical tab (\v not supported by json)
|
||||
map(trim), map(ltrim), map(rtrim)
|
||||
[" \n\t\r\f\u000b", ""," ", "a", " a ", "abc", " abc ", " abc", "abc "]
|
||||
["", "", "", "a", "a", "abc", "abc", "abc", "abc"]
|
||||
["", "", "", "a", "a ", "abc", "abc ", "abc", "abc "]
|
||||
["", "", "", "a", " a", "abc", " abc", " abc", "abc"]
|
||||
|
||||
trim, ltrim, rtrim
|
||||
"\u0009\u000A\u000B\u000C\u000D\u0020\u0085\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u2028\u2029\u202F\u205F\u3000abc\u0009\u000A\u000B\u000C\u000D\u0020\u0085\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u2028\u2029\u202F\u205F\u3000"
|
||||
"abc"
|
||||
"abc\u0009\u000A\u000B\u000C\u000D\u0020\u0085\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u2028\u2029\u202F\u205F\u3000"
|
||||
"\u0009\u000A\u000B\u000C\u000D\u0020\u0085\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u2028\u2029\u202F\u205F\u3000abc"
|
||||
|
||||
try trim catch ., try ltrim catch ., try rtrim catch .
|
||||
123
|
||||
"trim input must be a string"
|
||||
"trim input must be a string"
|
||||
"trim input must be a string"
|
||||
|
||||
indices(1)
|
||||
[0,1,1,2,3,4,1,5]
|
||||
[1,2,6]
|
||||
|
||||
Generated
+6
@@ -602,6 +602,12 @@ combinations(2)
|
||||
["fo", "foo", "barfoo", "foobar", "foob"]
|
||||
["fo","","bar","foobar","foob"]
|
||||
|
||||
trim, ltrim, rtrim
|
||||
" abc "
|
||||
"abc"
|
||||
"abc "
|
||||
" abc"
|
||||
|
||||
explode
|
||||
"foobar"
|
||||
[102,111,111,98,97,114]
|
||||
|
||||
Reference in new issue
Block a user