Re: regexp_replace - Mailing list pgsql-general

From Andy Colson
Subject Re: regexp_replace
Date
Msg-id 56980034.4080306@squeakycode.net
Whole thread Raw
In response to Re: regexp_replace  (John McKown <john.archie.mckown@gmail.com>)
List pgsql-general
On 1/14/2016 2:02 PM, John McKown wrote:
> How about:
>
> select regexp_replace('71.09.6.01.3', '(\d)[.-]', '\1', 'g');
>
> match is 1.3 and result is 13 ( 71096.013). If you don't want to
> eliminate the period or dash unless it is _between_ two digits, try:
>
> select regexp_replace('71.09.6.01.3', '(\d)[.-](?=\d)', '\1', 'g');
>
> (?=\d) is a "look ahead") match which says that the period or dash must
> be followed by a digit, but the expression _does not_ "consume" the
> digit matched.
>
>
>
> Maranatha! <><
> John McKown

Yes, excellent, both seem to work.  I'll run a bunch of data through
them both and see what happens.

Thanks much for the help!

-Andy



pgsql-general by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: regexp_replace
Next
From: Andy Colson
Date:
Subject: Re: regexp_replace