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 11:42:57 -0400
Message-ID: <20160407154255.GD4082@localhost.localdomain> (raw)
In-Reply-To: <3BBE635F64E28D4C899377A61DAA9FE04530581C@NBSVR-MAIL01.radiantblue.local>
References: <3BBE635F64E28D4C899377A61DAA9FE04530581C@NBSVR-MAIL01.radiantblue.local>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgus-general>
On Wed, Apr 06, 2016 at 06:31:42PM +0000, FBurgess@Radiantblue.com wrote:
> * Trying to build a regular expression syntax that doesn't drop the last digit (5) at the very end of the phone number.
>
> testdb=# select substring('OfficeName: abc office supply PhoneNumber: [commercial] 865-999-5695 ' from 'PhoneNumber: \[commercial](.*?)(,|(\d\s+))');
You have two parens in there - the reason you are not getting the last digit is that the first parens (.*?) scoops
up everything - including a leading space - up to the second parens (,|(\d\s+)), which ensures that the final digit
plus whitespace combination is always excluded from the first match.
That's a very specific regex. Can you simply slurp a phone number directly, like so?:
substring('OfficeName: abc office supply PhoneNumber: [commercial] 865-999-5695 ' from '([\d\-]+)')
--
Greg Sabino Mullane greg@endpoint.com
End Point Corporation
PGP Key: 0x14964AC8
Attachments:
[application/pgp-signature] signature.asc (162B, ../20160407154255.GD4082@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: <20160407154255.GD4082@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