Re: Splitting a string containing a numeric value in to three parts

From: Sanjaya Vithanagama <svithanagama(at)gmail(dot)com>
To: Kevin Grittner <kgrittn(at)ymail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Splitting a string containing a numeric value in to three parts
Date: 2015-07-28 00:36:52
Message-ID: CAMbKYy=5OQDq1x6TEEWuUgnsfXdGzZLHHxDzGM=OHonPRUYCMw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thank you Kevin! I missed the start of string and end of string matching.

On Tue, Jul 28, 2015 at 1:06 AM, Kevin Grittner <kgrittn(at)ymail(dot)com> wrote:

> Sanjaya Vithanagama <svithanagama(at)gmail(dot)com> wrote:
>
> > I can match the numeric value and the rest of the string after
> > the numeric value using the following:
> >
> > select regexp_matches('hello+123123.453the-123re',
> >
> '([\+|-]?(?:\d*(?:(?:\.)?\d+)))(.*)')
> > outputs array {+123123.453,the-123re}.
> >
> > Where I am having trouble is with matching the first part of the
> > string. In other words what needs to be 'RE' in the following
> > expression for it to report the all three elements of the array.
> >
> > select regexp_matches('hello+123123.453the-123re',
> >
> '((RE)[\+|-]?(?:\d*(?:(?:\.)?\d+)))(.*)')
> > should return array {hello,+123123.453,the-123re}.
>
> select regexp_matches('hello+123123.453the-123re',
> '^(.*?)([\+|-]?(?:\d*(?:(?:\.)?\d+)))(.*)$')
>
> --
> Kevin Grittner
> EDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>

--
Sanjaya

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Amit Bondwal 2015-07-28 04:04:35 Re: Postgres SSL connection without client certificates.
Previous Message Heikki Linnakangas 2015-07-27 20:52:18 Re: Lots of stuck queries after upgrade to 9.4