Re: How to remove a set of characters in text-columns ?

From: Tim Landscheidt <tim(at)tim-landscheidt(dot)de>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: How to remove a set of characters in text-columns ?
Date: 2011-07-01 02:17:55
Message-ID: m37h82lp64.fsf@passepartout.tim-landscheidt.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Andreas 2011-07-01 02:43:04 Re: How to remove a set of characters in text-columns ?
Previous Message Charlie 2011-06-30 19:57:08 Re: [SQL] How to remove a set of characters in text-columns ?