Re: regexp_replace

From: Andy Colson <andy(at)squeakycode(dot)net>
To: John McKown <john(dot)archie(dot)mckown(at)gmail(dot)com>
Cc: pgsql <pgsql-general(at)postgresql(dot)org>
Subject: Re: regexp_replace
Date: 2016-01-14 20:08:20
Message-ID: 56980034.4080306@squeakycode.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Andy Colson 2016-01-14 20:27:14 Re: regexp_replace
Previous Message David G. Johnston 2016-01-14 20:06:39 Re: regexp_replace