Re: Allow Reg Expressions in Position function

From: Ken Tanzer <ken(dot)tanzer(at)gmail(dot)com>
To: postgresql(at)walla(dot)co(dot)il
Cc: "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Allow Reg Expressions in Position function
Date: 2018-08-20 07:31:24
Message-ID: CAD3a31Vy3RAmW56GpztNchOxKf8JOk4sPpT=VMXT237WHxpq-Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

If I correctly understood what you wanted based on the SO description
("Something like: select position ('/s/' or '/b/' or '/t/' in URL)"),

you could do that by combining SUBSTRING with position. Something like:

SELECT position(substring(URL FROM '/(s|b|t)/') IN URL);

Cheers,

Ken

On Sun, Aug 19, 2018 at 11:27 PM Nick Dro <postgresql(at)walla(dot)co(dot)il> wrote:

> Position function allows only string as pattern parameter:
>
> select position(sub-string in string)
>
> If you are looking for more than one sub-string you can't do it with a
> single call to position.
> More info:
>
> https://stackoverflow.com/questions/51925037/how-to-find-position-of-multiple-sub-string-in-postgresql
>
>
> Required solution: make sub-string accept regular expression just like the
> LIKE operator.
>

--
AGENCY Software
A Free Software data system
By and for non-profits
*http://agency-software.org/ <http://agency-software.org/>*
*https://demo.agency-software.org/client
<https://demo.agency-software.org/client>*
ken(dot)tanzer(at)agency-software(dot)org
(253) 245-3801

Subscribe to the mailing list
<agency-general-request(at)lists(dot)sourceforge(dot)net?body=subscribe> to
learn more about AGENCY or
follow the discussion.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Nick Dro 2018-08-20 08:22:00 RE: Re: Allow Reg Expressions in Position function
Previous Message TalGloz 2018-08-20 07:11:56 Re: including header files in a C extension