title: swift 3 get start index (as int) of substring
body: <p>I would like to get the start and end position of a substring within a string. Example: in the string "hi this is my name"; if I provide the string "this" I would like to know the start index is 4 and end index is 7.</p>
  
  <p>I found several links, including this one:</p>
  
  <p><a href="https://stackoverflow.com/questions/32105260/swift-get-index-of-start-of-">Swift: get index of start of a substring in a string</a>
  a-substring-in-a-string</p>
  
  <p>But it doesn´t work in swift 3 as the method is now called range.</p>
  
  <p>I am now using this:</p>
  
  <pre><code>let range = mystring.range(of: "StringSearch")?.lowerBound
  </code></pre>
  
  <p>which returns this</p>
  
  <pre><code>Swift.String.UnicodeScalarView.Index(_position: 15), _countUTF16: 1))
  </code></pre>
  
  <p>And I cannot obtain the position as an integer as this is an index.</p>
  
  <p>In summary, I would like to have in a variable of type int the position, in this case 15.</p>
  
  <p>Can anyone help me?</p>
  
  <p>Thanks everyone.</p>