Re: [Urgent] Regexp_replace question

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Phoenix Kiula <phoenix(dot)kiula(at)gmail(dot)com>
Cc: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: [Urgent] Regexp_replace question
Date: 2007-09-25 06:46:38
Message-ID: 20070925064638.GA34028@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Sep 25, 2007 at 01:36:26PM +0800, Phoenix Kiula wrote:
> How can I remove characters that form a part of regular expressions?

Why do you want to do that?

> I would like to remove all instances of the following characters:
>
> [
> ]
> \
> +

test=> select id, t, regexp_replace(t, e'[\\\\[\\]+]', '', 'g') from foo;
id | t | regexp_replace
----+------------+----------------
1 | foo[]+\bar | foobar
(1 row)

test=> select id, t, translate(t, e'[]\\+', '') from foo;
id | t | translate
----+------------+-----------
1 | foo[]+\bar | foobar
(1 row)

--
Michael Fuhr

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Petri Simolin 2007-09-25 06:55:37 UNIQUE_VIOLATION exception, finding out which index would have been violated
Previous Message Petri Simolin 2007-09-25 05:57:42 UNIQUE_VIOLATION, Finding out which index would have been violated