Here is a refer to the stackoverflow question:

http://stackoverflow.com/questions/42974822/find-sub-string-position-from-the-end-of-string-in-postgresql
 
it carry another example and the solution however I still think that this fuctionality should be avliable in a build-in postgresql function.
 



ב מרץ 27, 2017 19:58, Adrian Klaver כתב:
On 03/27/2017 09:15 AM, David G. Johnston wrote:
> On Mon, Mar 27, 2017 at 9:03 AM, Brian Dunavant > >wrote:
>
> That does not return the correct answer for the original poster's
> request.
>
> flpg=#
> ​​
> select position('om' in reverse('Tomomasaaaaaaaaaaa'));
> position
> ----------
> 15
> (1 row)
>
>
> ​Easy oversight to make - if you reverse the string being searched you
> must also reverse the string that you are looking for.
>
> That said the OP hasn't actually defined what they mean by "locate" when
> considered in a backward sense - some length adjustments might be needed
> to compensate for the length of the term being searched for.

I think there is also a RTL language involved, so we may need more
information to answer the question.

>
> Patches are welcomed. Given the lack of any links to previous requests
> of this nature I'd say its not exactly a highly in-demand capability.
>
> David J.
>


--
Adrian Klaver
adrian.klaver@aklaver.com