replace()

A function for replacing parts of a string with another string

replace() is a system function for replacing parts of a string with another string.

replace() was added in PostgreSQL 7.3.

Usage

replace ( string text, from text, to text ) → text

Change history

Examples

Basic usage example for replace():

postgres=# SELECT replace('foobar','bar','baz');
 replace
---------
 foobaz
(1 row)

does of course work with multibyte characters:

postgres=# SELECT replace('わくわく','わく','ほげ');
 replace
----------
 ほげほげ
(1 row)

Categories

String manipulation, System function

See also

array_replace(), regexp_replace()