https://issues.qgis.org/https://issues.qgis.org/favicon.ico2019-02-07T00:05:16ZQGIS Issue TrackingQGIS Application - Bug report #21192: substr function in Select by Expression behaving strangehttps://issues.qgis.org/issues/21192?journal_id=996482019-02-07T00:05:16ZJürgen Fischerjef@norbit.de
<ul></ul><p>Not reproducable here:</p>
<pre>
substr('NL1234',0,2) => 'NL'
substr('NL1234',1,2) => 'NL'
substr('NL1234',0,3) => 'NL1'
</pre> QGIS Application - Bug report #21192: substr function in Select by Expression behaving strangehttps://issues.qgis.org/issues/21192?journal_id=996492019-02-07T00:05:30ZJürgen Fischerjef@norbit.de
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Feedback</i></li></ul> QGIS Application - Bug report #21192: substr function in Select by Expression behaving strangehttps://issues.qgis.org/issues/21192?journal_id=996552019-02-07T09:08:52ZRichard Duivenvoorde
<ul></ul><p>Mmm, strange. So the last example I cannot reproduce here either.</p>
<p>But my point that it is not clear if it is zero based or one based is still valid:</p>
<p>substr('NL1234',0,2) => 'NL'<br />substr('NL1234',1,2) => 'NL'</p>
<p>But we could consider this a 'feature'...<br />Problem would have been bigger if the second parameter would have been the end-stop instead of the length....</p>
<p>Close?</p> QGIS Application - Bug report #21192: substr function in Select by Expression behaving strangehttps://issues.qgis.org/issues/21192?journal_id=996612019-02-07T10:17:25ZJürgen Fischerjef@norbit.de
<ul></ul><p>Richard Duivenvoorde wrote:</p>
<blockquote>
<p>Mmm, strange. So the last example I cannot reproduce here either.</p>
<p>But my point that it is not clear if it is zero based or one based is still valid:</p>
<p>substr('NL1234',0,2) => 'NL'<br />substr('NL1234',1,2) => 'NL'</p>
<p>But we could consider this a 'feature'...<br />Problem would have been bigger if the second parameter would have been the end-stop instead of the length....</p>
<p>Close?</p>
</blockquote>
<p>The help doesn't say where the indexes start - but the examples show the current behavior (ie. index start at 1 - like in postgresql for instance; postgresql however produces an empty string on <code>substring('NL1234',0,1)</code> and 'N' on <code>substring('NL1234',0,2)</code>). Except</p>
<pre>
substr('HELLO WORLD',6) → 'WORLD'
</pre> QGIS Application - Bug report #21192: substr function in Select by Expression behaving strangehttps://issues.qgis.org/issues/21192?journal_id=996622019-02-07T10:17:47ZJürgen Fischerjef@norbit.de
<ul><li><strong>% Done</strong> changed from <i>0</i> to <i>100</i></li><li><strong>Status</strong> changed from <i>Feedback</i> to <i>Closed</i></li></ul><p>Applied in changeset <a class="changeset" href="https://issues.qgis.org/projects/qgis/repository/revisions/2bed7ab0018696dba76d2c8053d22633a271486e" title="fix substr help (fixes #21192)">qgis|2bed7ab0018696dba76d2c8053d22633a271486e</a>.</p>