regexp_replace

From: Andy Colson <andy(at)squeakycode(dot)net>
To: pgsql <pgsql-general(at)postgresql(dot)org>
Subject: regexp_replace
Date: 2016-01-14 19:43:27
Message-ID: 5697FA5F.2020703@squeakycode.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi all.

This is not doing as I'd expected:

select regexp_replace('71.09.6.01.3', '(\d)[.-](\d)', '\1\2', 'g');

regexp_replace
----------------
71096.013
(1 row)

It acts the same with dashes:
select regexp_replace('71-09-6-01-3', '(\d)[.-](\d)', '\1\2', 'g');

regexp_replace
----------------
71096-013
(1 row)

I cannot use translate because there is other text in the field. I'm
trying to strip masking characters from a parcel number in a larger text
field (for example: "the parcel 12-34-56 has caught on fire")

I seem to be missing something, any hints?

I'm on PG 9.3.9 on Slackware64.

Thanks for your time,

-Andy

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2016-01-14 19:59:03 Re: regexp_replace
Previous Message Nikhil 2016-01-14 19:41:12 Postgres BDR bdr_init_copy fails