Contents
btrim()
A system function which trims characters from both sides of a string
btrim()
is a system function which trims characters (default: spaces) from both sides of a string.
btrim()
was added in PostgreSQL 6.1.
Usage
btrim ( string text [, characters text ] ) → text
btrim()
is a convenience/compatibility function equivalent to the SQL standard trim():
postgres=# SELECT btrim(' foobar '), trim(BOTH FROM ' foobar '); btrim | btrim --------+-------- foobar | foobar (1 row)
Change history
- PostgreSQL 6.1
- added (commit 3c2d74d2)
Examples
Remove all instances of !
, ?
and #
from both sides of a string:
postgres=# SELECT btrim('!#foo##bar??', '!?#'); btrim ---------- foo##bar (1 row)
References
- PostgreSQL documentation: Other String Functions