Re: How to remove a set of characters in text-columns ? - Mailing list pgsql-sql

From Tim Landscheidt
Subject Re: How to remove a set of characters in text-columns ?
Date
Msg-id m37h82lp64.fsf@passepartout.tim-landscheidt.de
Whole thread Raw
In response to How to remove a set of characters in text-columns ?  (Andreas <maps.on@gmx.net>)
Responses Re: How to remove a set of characters in text-columns ?  (Andreas <maps.on@gmx.net>)
List pgsql-sql
(anonymous) wrote:

> how can I remove a set of characters in text-columns ?
> Say I'd like to remove { } ( ) ' " , ; . : !
> Of course I can chain replace ( replace ( replace ( replace
> ( ... , '' ) .... and replace the chars one by one against
> an empty string ''.

> There might be a more elegant way.
> Is there ?

Besides the regexp_replace() solution mentioned by Charlie
and Steve, you can also use TRANSLATE():

| tim=# SELECT TRANSLATE('a{b''c"d!f', '{}()''",;.:!', '');
|  translate
| -----------
|  abcdf
| (1 Zeile)

| tim=#

Tim



pgsql-sql by date:

Previous
From: Charlie
Date:
Subject: Re: [SQL] How to remove a set of characters in text-columns ?
Next
From: Andreas
Date:
Subject: Re: How to remove a set of characters in text-columns ?