RE: Re: Re: Allow Reg Expressions in Position function

From: Nick Dro <postgresql(at)walla(dot)co(dot)il>
To: pgsqladmin(at)geoff(dot)dj, ken(dot)tanzer(at)gmail(dot)com, pgsql-general(at)lists(dot)postgresql(dot)org
Cc: <ken(dot)tanzer(at)gmail(dot)com>, <pgsql-general(at)lists(dot)postgresql(dot)org> <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: RE: Re: Re: Allow Reg Expressions in Position function
Date: 2018-08-20 13:46:42
Message-ID: ^22D695F5F6F276172F0625A5685FD68B121B2ACB@walla.co.il
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

<div><div dir="rtl"><div dir="ltr"><br>Hi,</div>
<div dir="ltr">My specific issue is alrady solved.</div>
<div dir="ltr">For the greater good I sent the email requesting to allow reg exp in the position functions.</div>
<div dir="ltr">Not sure if you will implement it... Just wanted to let you know that the limited capabilities of this function create overhead.</div></div><section class="cust_msg_end"></section><blockquote style="margin:0;margin-bottom:20px;border-top:1px solid #e0e0e0;"><br>ב אוג׳ 20, 2018 14:35, Geoff Winkless כתב:<blockquote style="margin:0;margin-bottom:20px;border-top:1px solid #e0e0e0">
<div dir="ltr"><div style="font-family:verdana,sans-serif;font-size:small"><span style="font-family:Arial,Helvetica,sans-serif">On Mon, 20 Aug 2018 at 09:22, Nick Dro &lt;<a href="mailto:postgresql(at)walla(dot)co(dot)il">postgresql(at)walla(dot)co(dot)il</a>&gt; wrote:</span><br></div><div><blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div dir="rtl"><div><br>

<div dir="ltr">This incorrect.</div>
<div dir="ltr">SELECT position(substring('<a href="https://www.webexample.com/s/help" target="_blank">https://www.webexample.com/s/help</a>?' FROM '/(s|b|t)/') IN '<a href="https://www.webexample.com/s/help?'" target="_blank">https://www.webexample.com/s/help?'</a>);</div>
<div dir="ltr">&nbsp;</div>
<div dir="ltr">Gives 5. It's wrong.</div></div></div></div></blockquote><div><br></div><div style="font-family:verdana,sans-serif;font-size:small"></div><br><br><div><div dir="ltr">On Mon, 20 Aug 2018 at 09:22, Nick Dro &lt;<a href="mailto:postgresql(at)walla(dot)co(dot)il">postgresql(at)walla(dot)co(dot)il</a>&gt; wrote:<br></div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div dir="rtl"><div><br><div dir="ltr">This incorrect.</div><div dir="ltr">SELECT position(substring('<a href="https://www..webexample.com/s/help" target="_blank">https://www.webexample.com/s/help</a>?' FROM '/(s|b|t)/') IN '<a href="https://www.webexample.com/s/help?%27" target="_blank">https://www.webexample.com/s/help?'</a>);</div><div dir="ltr">&nbsp;</div><div dir="ltr">Gives 5. It's wrong.</div></div></div></div></blockquote><div><br></div><div style="font-family:verdana,sans-serif">For some reason, substring() returns the parenthesised subexpression rather than the top level..</div><div style="font-family:verdana,sans-serif"><br></div><div style="font-family:verdana,sans-serif">The comment in testregexsubstr does say that it does this, but it's not clear from the documentation at all, unless I'm missing where it says it.</div><div style="font-family:verdana,sans-serif"><br></div><div style="font-family:verdana,sans-serif">You can work around this by putting parentheses around the whole expression, because that way the first subexpression is the whole match.</div><div style="font-family:verdana,sans-serif"><br></div><div style="font-family:verdana,sans-serif"><div>db=# SELECT position(substring('<a href="https://www.webexample.com/s/help">https://www.webexample.com/s/help</a>?' FROM '(/(s|b|t)/)') IN '<a href="https://www.webexample.com/s/help?'">https://www.webexample.com/s/help?'</a>);</div><div>&nbsp;position</div><div>----------</div><div>&nbsp; &nbsp; &nbsp; &nbsp;27</div><div><br></div></div></div><div style="font-family:verdana,sans-serif;font-size:small">Geoff</div></div></div>

<br></blockquote></blockquote><br></div>

Attachment Content-Type Size
unknown_filename text/html 3.3 KB

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Daniel Verite 2018-08-20 13:47:26 Re: Linker errors while creating a PostgreSQL C extension function.
Previous Message Geoff Winkless 2018-08-20 11:35:23 Re: Re: Allow Reg Expressions in Position function