In this PostgreSQL post explains how to use the PostgreSQL trim function with syntax and examples.
The PostgreSQL trim function removes all specified characters either from the beginning or the end of a string.
The syntax for the trim function in PostgreSQL is:
Remove trim_character from the front of string.
Remove trim_character from the end of string.
Remove trim_character from the front and end of string.
The set of characters that will be removed from string. If this parameter is omitted, the trim function will remove space characters from string.
The string to trim.
The trim function can be used in the following versions of PostgreSQL:
Let's look at some PostgreSQL trim function examples and explore how to use the trim function in PostgreSQL.
For example:
(Please note that for each of the example results below, we have included single quotes around the result to demonstrate what the trim function returns in PostgreSQL. If you ran these commands yourself, you would not see the single quotes in the result):