From: | Greg Sabino Mullane <greg(at)endpoint(dot)com> |
---|---|
To: | "FBurgess(at)Radiantblue(dot)com" <FBurgess(at)Radiantblue(dot)com> |
Cc: | "pgus-general(at)postgresql(dot)org" <pgus-general(at)postgresql(dot)org> |
Subject: | Re: PostgreSQL POSIX regular expression problem |
Date: | 2016-04-07 15:42:57 |
Message-ID: | 20160407154255.GD4082@localhost.localdomain |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgus-general |
On Wed, Apr 06, 2016 at 06:31:42PM +0000, FBurgess(at)Radiantblue(dot)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(at)endpoint(dot)com
End Point Corporation
PGP Key: 0x14964AC8
From | Date | Subject | |
---|---|---|---|
Next Message | FBurgess@Radiantblue.com | 2016-04-07 16:16:41 | Re: PostgreSQL POSIX regular expression problem |
Previous Message | FBurgess@Radiantblue.com | 2016-04-06 18:31:42 | PostgreSQL POSIX regular expression problem |