Re: find and replace the string within a column - Mailing list pgsql-sql

From Leif Biberg Kristensen
Subject Re: find and replace the string within a column
Date
Msg-id 201009241639.07557.leif@solumslekt.org
Whole thread Raw
In response to Re: find and replace the string within a column  (Craig Ringer <craig@postnewspapers.com.au>)
List pgsql-sql
On Friday 24. September 2010 13.34.12 Craig Ringer wrote:
> On 24/09/2010 5:15 PM, Nicholas I wrote:
> 
> > Example:
> > table name person:
> >
> > name
> > ------------------------------------
> > Samuel (S/o Sebastin )
> > -------------------------------------
> >
> > remove the word within the brackets.
> > the output should be , Samuel.
> 
> Can't you just regexp_replace, matching \([^)]+\) (in other words "an 
> open parenthisis, then a sequence of one or more of any character other 
> than a close parenthesis, followed by a close parentheis) and replacing 
> with an empty string ?

I'm doing a similar task, removing comments "hidden" within curly braces like 
this:
       str := REGEXP_REPLACE(str, '{.*?}', '', 'g');

No escaping needed at all.

regards,
Leif Biberg Kristensen



pgsql-sql by date:

Previous
From: Guillaume Lelarge
Date:
Subject: Re: pgdump with insert command help
Next
From: "Tarlika Elisabeth Schmitz"
Date:
Subject: Re: identifying duplicates in table with redundancies