PostgreSQL/String Functions/btrim

Материал из SQL эксперт
Перейти к: навигация, поиск

btrim("123example 332", "123")

postgres=#
postgres=# SELECT btrim("123example 332", "123") AS trim_numbers;
 trim_numbers
--------------
 example
(1 row)
postgres=#



btrim(s [, t]): Returns character string s

postgres=# -- btrim(s [, t]): Returns character string s, trimmed on the left and right 
of any substrings consisting solely of letters in character string t 
(or whitespace, if t is not specified)
postgres=#
postgres=# SELECT btrim("  whitespace example   ") AS trim_blanks;
    trim_blanks
--------------------
 whitespace example
(1 row)
postgres=#
postgres=#



Remove the longest string consisting only of bytes in bytes from the start and

postgres=#
postgres=# -- btrim(string bytea, bytes bytea)
postgres=# -- Remove the longest string consisting only of bytes in bytes from the start and
postgres=# -- end of string
postgres=#
postgres=# select btrim("\\000trim\\000"::bytea, "\\000"::bytea);
 btrim
-------
 trim
(1 row)
postgres=#
postgres=#