Re: Request to add feature to the Position function - Mailing list pgsql-general

From Adrian Klaver
Subject Re: Request to add feature to the Position function
Date
Msg-id a6d5725a-2b9e-c6cd-205d-96063ed401a9@aklaver.com
Whole thread Raw
In response to Request to add feature to the Position function  (Ron Ben <ronb910@walla.co.il>)
Responses Re: Request to add feature to the Position function
List pgsql-general
On 03/27/2017 08:05 AM, Ron Ben wrote:
> Hi,
> position(substring in string)
> as listed here:
> https://www.postgresql.org/docs/9.1/static/functions-string.html
> locates sub string in a string.
>
> It doesn't support locateing the substring from the back.
>
> For example:
>
> position('om' in 'Tomomas')
> gives 2
>
> But if I want to locate the first occurance from the back of the string
> it's impossible/

aklaver@test=> select position('om' in reverse('Tomomas'));
  position
----------
         4

>
> My suggestion is to create a function
> position(substring in string,order)
> where order can be: begin, end
>
> and it will find the string according to this parameter.
> This is pretty easy to implement and should be a part of the PostgreSQL
> tools.
>
> similar fuctionality exists in trim function where user can specify
> leading or taling parameter


--
Adrian Klaver
adrian.klaver@aklaver.com


pgsql-general by date:

Previous
From: Ron Ben
Date:
Subject: Request to add feature to the Position function
Next
From: Brian Dunavant
Date:
Subject: Re: Request to add feature to the Position function