rtrim
This function is used to remove characters from the right of str.
- If trimChars is not specified, spaces are removed by default.
- If trimChars is specified, the function removes the longest possible substring from the right end of str that consists of characters in the trimChars set.
Similar functions:
- ltrim. This function is used to remove characters from the left of str.
- trim. This function is used to remove characters from the left and right of str.
Syntax
rtrim([<trimChars>, ]string <str>)
or
rtrim(trailing [<trimChars>] from <str>)
Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
str |
Yes |
STRING |
String from which characters on the right are to be removed. If the value is of the BIGINT, DECIMAL, DOUBLE, or DATETIME type, the value is implicitly converted to the STRING type for calculation. |
trimChars |
Yes |
STRING |
Characters to be removed |
Return Values
The return value is of the STRING type.
- If the value of str is not of the STRING, BIGINT, DOUBLE, DECIMAL, or DATETIME type, an error is reported.
- If the value of str or trimChars is NULL, NULL is returned.
Example Code
- Removes spaces on the right of the string yxabcxx. An example command is as follows:
The value yxabcxx is returned.
select rtrim('yxabcxx ');
It is equivalent to the following statement:
select trim(trailing from ' yxabcxx ');
- Removes all substrings from the right end of the string yxabcxx that consist of characters in the set xy.
The function returns yxabc, as any substring starting with x or y from the right end is removed.
select rtrim('xy', 'yxabcxx');
It is equivalent to the following statement:
select trim(trailing 'xy' from 'yxabcxx');
- The value of the input parameter is NULL. An example command is as follows:
The value NULL is returned.
select rtrim(null); select ltrim('yxabcxx', 'null');
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot