regexp_replace behavior

From: Marcin Krawczyk <jankes(dot)mk(at)gmail(dot)com>
To: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: regexp_replace behavior
Date: 2012-11-20 14:43:18
Message-ID: CABnqL301mDLD5UwXfLcUprk2EMt7c5JzJKJz_icAHyx3fN61Vg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi list,

I'm trying to use regexp_replace to get rid of all occurrences of
certain sub strings from my string.
What I'm doing is:

SELECT regexp_replace('F0301 305-149-101-0 F0302 {x1} 12W47 0635H
{tt}{POL23423423}', E'\{.+\}', '', 'g')

so get rid of whatever is between { } along with these,

but it results in:
'F0301 305-149-101-0 F0302 '

how do I get it to be:
'F0301 305-149-101-0 F0302 12W47 0635H'

??

as I understood the docs, the g flag "specifies replacement of each
matching substring rather than only the first one"
what am I missing ?

regards
mk

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Alvaro Herrera 2012-11-20 14:55:08 Re: regexp_replace behavior
Previous Message Louis-David Mitterrand 2012-11-19 10:09:46 Re: organizing cron jobs in one function