Thread: regexp_replace

regexp_replace

From
"Marcin Krawczyk"
Date:
Hi all. I'd like to know whether it's possible to reverse the
behaviour of regexp_replace, meaning :
now if I do
SELECT regexp_replace ('foobarbaz', 'b..', 'X') I get 'fooXbaz' - it
replaces the string that matches given pattern with 'X', how do I
achieve the opposite - replace the string that doesn't match the
pattern ?

regards
mk


Re: regexp_replace

From
"Pawel Socha"
Date:
<div dir="ltr">2008/8/1 Marcin Krawczyk <span dir="ltr"><<a href="http://jankes.mk">jankes.mk</a>@<a
href="http://gmail.com">gmail.com</a>></span><br/><div class="gmail_quote"><blockquote class="gmail_quote"
style="border-left:1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> Hi all. I'd like to
knowwhether it's possible to reverse the<br /> behaviour of regexp_replace, meaning :<br /> now if I do<br /> SELECT
regexp_replace('foobarbaz', 'b..', 'X') I get 'fooXbaz' - it<br /> replaces the string that matches given pattern with
'X',how do I<br /> achieve the opposite - replace the string that doesn't match the<br /> pattern ?<br /><br />
regards<br/> mk<br /><font color="#888888"><br /> --<br /> Sent via pgsql-sql mailing list (<a
href="mailto:pgsql-sql@postgresql.org">pgsql-sql@postgresql.org</a>)<br/> To make changes to your subscription:<br /><a
href="http://www.postgresql.org/mailpref/pgsql-sql"target="_blank">http://www.postgresql.org/mailpref/pgsql-sql</a><br
/></font></blockquote></div><br/><br clear="all" /><br clear="all" />merlin=# SELECT regexp_replace ('foobarbaz',
'[^b]','X', 'g');<br /> regexp_replace<br />----------------<br /> XXXbXXbXX<br />(1 row)<br /><br /><br />-- <br
/>--<br/>Serdecznie pozdrawiam<br /><br />Pawel Socha<br /><a
href="mailto:pawel.socha@gmail.com">pawel.socha@gmail.com</a><br/><br />programista/administrator<br /><br />perl -le
's**02).4^&-%2,).^9%4^!./4(%2^3,!#+7!2%^53%2&**y%&-;^[%"`-{ a%%s%%$_%ee'<br /></div> 

Re: regexp_replace

From
"Marcin Krawczyk"
Date:
thanks / dzieki

regards / pozdrowienia
mk

2008/8/1 Pawel Socha <pawel.socha@gmail.com>:
> 2008/8/1 Marcin Krawczyk <jankes.mk@gmail.com>
>>
>> Hi all. I'd like to know whether it's possible to reverse the
>> behaviour of regexp_replace, meaning :
>> now if I do
>> SELECT regexp_replace ('foobarbaz', 'b..', 'X') I get 'fooXbaz' - it
>> replaces the string that matches given pattern with 'X', how do I
>> achieve the opposite - replace the string that doesn't match the
>> pattern ?
>>
>> regards
>> mk
>>
>> --
>> Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgsql-sql
>
>
>
> merlin=# SELECT regexp_replace ('foobarbaz', '[^b]', 'X', 'g');
>  regexp_replace
> ----------------
>  XXXbXXbXX
> (1 row)
>
>
> --
> --
> Serdecznie pozdrawiam
>
> Pawel Socha
> pawel.socha@gmail.com
>
> programista/administrator
>
> perl -le 's**02).4^&-%2,).^9%4^!./4(%2^3,!#+7!2%^53%2&**y%& -;^[%"`-{
> a%%s%%$_%ee'
>