TRIM
語法
TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM] str)
序號 | 函數 | 函數結果 | 備注 |
1 | trim(' test ') | 'test' | 刪除字符串前后空格 |
2 | trim(both from ' test ') | 'test' | 'both'參數表示同時去除字符串前后所指定的內容(默認情況下刪除空格) |
3 | trim(trailing from ' test ') | ' test' | 'trailing'參數表示刪除字符串尾部空格 |
4 | trim(leading from ' test ') | 'test ' | 'leading'參數表示刪除字符串頭部空格 |
5 | trim('x' from 'xxxtestxxx') | 'test' | 刪除字符串前后的字符'x' |
6 | trim(both 'x' from 'xxxtestxxx') | 'test' | 刪除字符串前后的字符'x' |
7 | trim(trailing 'xy' from 'xyxyxtestxxyxy') | 'xyxyxtestx' | 刪除字符串尾部的字符串'xy' |
8 | trim(leading 'xy' from 'xyxyxtestxxyxy') | 'xtestxxyxy' | 刪除字符串頭部的字符串'xy' |
9 | trim(leading 'xy' from trim(trailing 'xy' from 'xyxtestxxy')) | 'xtestx' | 刪除字符串頭尾的字符'xy' |
LTRIM / RTRIM
去掉字符串左/右邊的空格
序號 | 函數 | 函數結果 | 備注 |
1 | ltrim(' test ') | 'test ' | 去掉字符串左邊的空格 |
2 | rtrim(' test ') | ' test' | 去掉字符串右邊的空格 |
3 |