w3resource

PostgreSQL RTRIM() function

RTRIM() function

The PostgreSQL rtrim function is used to remove spaces( if no character(s) is provided as trimming_text ) or set of characters which are matching with the trimming_text, from the end of a string.

Syntax:

rtrim(<string> [, < trimming_text >])

PostgreSQL Version: 9.3

Pictorial Presentation of PostgreSQL RTRIM() function

Pictorial presentation of postgresql rtrim function

Example: PostgreSQL RTRIM() function:

In the example below, the matching text is 'best' mention in the second parameter in which 'e','s' and 't' is matching from the end of the first parameter and removed from the string.

Code:

SELECT rtrim('rtrimtest', 'best');

Sample Output:

 rtrim
-------
 rtrim
(1 row)

Example 2:

In the example below, no matching text is specified so the default white spaces have been removed from the end of the string.

Code:

SELECT rtrim('rtrim    ');

Sample Output:

 rtrim
-------
 rtrim
(1 row)

Previous: RPAD function
Next: SPLIT_PART function



Follow us on Facebook and Twitter for latest update.