From: Greg Sabino Mullane <greg@endpoint.com>
To: FBurgess@Radiantblue.com <FBurgess@Radiantblue.com>
Cc: pgus-general@postgresql.org <pgus-general@postgresql.org>
Subject: Re: PostgreSQL POSIX regular expression problem
Date: Thu, 7 Apr 2016 19:44:06 -0400
Message-ID: <20160407234406.GE4082@localhost.localdomain> (raw)
In-Reply-To: <3BBE635F64E28D4C899377A61DAA9FE04530599B@NBSVR-MAIL01.radiantblue.local>
References: <3BBE635F64E28D4C899377A61DAA9FE04530581C@NBSVR-MAIL01.radiantblue.local>
<20160407154255.GD4082@localhost.localdomain>
<3BBE635F64E28D4C899377A61DAA9FE045305942@NBSVR-MAIL01.radiantblue.local>
<3BBE635F64E28D4C899377A61DAA9FE04530599B@NBSVR-MAIL01.radiantblue.local>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgus-general>
If you want to just pull out the numbers, do a direct regexp_replace with
some (\d\d\d)\D* like so:
select regexp_replace('my phone: (904)-867 5309 ', '.*(\d\d\d)\D*(\d\d\d)\D*(\d\d\d\d).*$', '\1-\2-\3');
To grab something after a specific string appears (e.g. "Corporate"), add it in but
make sure the first dot-star becomes non-greedy with a question mark:
select regexp_replace('my phone: 904 867 5309 [Corporate] (703)-555-1234',
'.*?Corporate.*(\d\d\d)\D*(\d\d\d)\D*(\d\d\d\d).*$', '\1-\2-\3');
--
Greg Sabino Mullane greg@endpoint.com
End Point Corporation
PGP Key: 0x14964AC8
Attachments:
[application/pgp-signature] signature.asc (162B, ../20160407234406.GE4082@localhost.localdomain/2-signature.asc)
download
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgus-general@postgresql.org
Cc: greg@endpoint.com, FBurgess@Radiantblue.com
Subject: Re: PostgreSQL POSIX regular expression problem
In-Reply-To: <20160407234406.GE4082@localhost.localdomain>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox