title: Java - second last occurrence of char in string
body: <p>Suppose I've the string</p>
  
  <pre><code>String path = "the/quick/brown/fox/jumped/over/the/lazy/dog/";
  </code></pre>
  
  <p>I would like the following output</p>
  
  <pre><code>String output = "the/quick/brown/fox/jumped/over/the/lazy/";
  </code></pre>
  
  <p>I was thinking the following would do</p>
  
  <pre><code>output = path.substring(0, path.lastIndexOf("/", 1));
  </code></pre>
  
  <p>given how the doc says</p>
  
  <blockquote>
    <p>Returns the index of the first (last) occurrence of the specified character, searching forward (backward) from the specified index.</p>
  </blockquote>
  
  <p>but that doesn't seem to work.</p>
  
  <p>Any help would be appreciated.</p>