title: find last index of a string in swift
body: <p>In swift 4 you can use the following method to extract a substring:</p>
  
  <pre><code>let str = "abcdefghci"
  let index = str.index(of: "c") ?? str.endIndex
  print(str[...index])
  </code></pre>
  
  <p>This will print <code>abc</code></p>
  
  <p>But how can I find the index of the last <code>c</code>, to extract a substring from that location ?</p>
  
  <p><strong>UPDATE</strong><br>
  @vadian please see the attached image:</p>
  
  <p><a href="https://i.stack.imgur.com/S0fzq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/S0fzq.png" alt="enter image description here"></a></p>