Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id F21B6B5F4D3 for ; Thu, 30 Jun 2011 23:20:53 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 82544-04-6 for ; Fri, 1 Jul 2011 02:20:47 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from lo.gmane.org (lo.gmane.org [80.91.229.12]) by mail.postgresql.org (Postfix) with ESMTP id B3182B5DE80 for ; Thu, 30 Jun 2011 23:18:08 -0300 (ADT) Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1QcTJ0-0002cu-EW for pgsql-sql@postgresql.org; Fri, 01 Jul 2011 04:18:06 +0200 Received: from g224047025.adsl.alicedsl.de ([92.224.47.25]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 01 Jul 2011 04:18:06 +0200 Received: from tim by g224047025.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 01 Jul 2011 04:18:06 +0200 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: pgsql-sql@postgresql.org To: pgsql-sql@postgresql.org From: Tim Landscheidt Subject: Re: How to remove a set of characters in text-columns ? Date: Fri, 01 Jul 2011 02:17:55 +0000 Organization: Lines: 23 Message-ID: References: <4E0CCE6F.70001@gmx.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: g224047025.adsl.alicedsl.de Mail-Copies-To: never User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:D5eQyeKjh1rdWRnraa1+jyW3nFE= X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201106/103 X-Sequence-Number: 35569 (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