Re: Emulating flexible regex replace

From: David G Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Emulating flexible regex replace
Date: 2014-10-23 17:39:09
Message-ID: 1414085949598-5824065.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

David G Johnston wrote
>
> twoflower wrote
>> Source: 123 source text
>> Target: 123 target text
>> Source pattern: ([0-9]+) source text
>> Target pattern: $1 target text
>>
>> Still, isn't there some super clever way to do that?
> You use "\1" instead of "$1"
>
> SELECT regexp_replace('123 abc','(\d+)\s(\w+)','\1 def'); --output: '123
> def'
>
> http://www.postgresql.org/docs/9.3/static/functions-matching.html#FUNCTIONS-POSIX-REGEXP
>
> 9.7.3 - paragraph beginning "The regexp_replace function provides
> substitution..."
>
> David J.

<reading this a few more times>

Is it possible to express the WHERE clause as:

regexp_replace(source, source_pattern, target_pattern) = target

maybe with a substring check instead of equals?

David J.

--
View this message in context: http://postgresql.1045698.n5.nabble.com/Emulating-flexible-regex-replace-tp5824034p5824065.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joe Van Dyk 2014-10-23 20:40:10 some queries on standby preventing replication updates
Previous Message Francisco Olarte 2014-10-23 16:51:07 Emulating flexible regex replace