Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Does the message contain <code>last</code> at all? If not, <code>location</code> would be negative, and you should stop processing right there. This error might go unnoticed because you add 5 to <code>location</code> after that, which makes it equal to at least 4 even if <code>last</code> is not in the string (thanks <a href="https://stackoverflow.com/users/598289/sjuan76">SJuan76</a>).</p> <p>Even if the message contains <code>last</code>, is it guaranteed that it is followed by at least one extra character? If not, adding 5 to <code>location</code> would point outside the string for sure.</p> <p>Moreover, <code>end</code> may also be negative if there is no <code>&amp;</code> in the string after <code>location</code>. You should handle that somehow (i.e. by setting <code>end</code> to the length of the message in that case).</p> <p>Also, if <code>message</code> is a string, you can simply extract a substring of it using the <code>substring</code> method, no need for the <code>getChars</code> magic.</p> <p>A better solution would probably be something like this (I'm assuming that <code>message</code> is something like an URL and you are looking for the part between <code>last&gt;</code> and the next <code>&amp;</code>, based on your comment for one of the other answers):</p> <pre><code>location = message.indexOf("last&gt;"); if (location &gt;= 0) { String lastS; location += 5; end = message.indexOf('&amp;', location); if (end == -1) { // Handle the case when there is no "&amp;" after "last&gt;" in the message } else { lastS = message.substring(location, end); } } else { // Handle the case when there is no "last&gt;" in the message } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload