Re: postgres function

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Ramesh T <rameshparnanditech(at)gmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: postgres function
Date: 2015-10-15 13:02:11
Message-ID: CAKFQuwbNTaYbHtMbe5w+HGg5XXKe=JbT6P1VQEWUmVWWeR4qwQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Oct 15, 2015 at 8:32 AM, Ramesh T <rameshparnanditech(at)gmail(dot)com>
wrote:

> select position('-' in '123-987-123')
> position
> ---
> 4
> But I want second occurrence,
> position
> -------------
> 8
>
> plz any help..?
>
>

SELECT length((regexp_matches('123-987-123', '(\d{3}-\d{3}-)\d{3}'))[1])

David J.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2015-10-15 13:20:48 Re: Installing plpython3u
Previous Message Ramesh T 2015-10-15 12:32:51 Re: postgres function