title: Calculate range of string from word to end of string in swift
body: <p>I have an NSMutatableString:</p>
  
  <pre><code>var string: String = "Due in %@ (%@) $%@.\nOverdue! Please pay now %@"
  attributedText = NSMutableAttributedString(string: string, attributes: attributes)
  </code></pre>
  
  <p>How to calculate both the length and starting index from the word <code>Overdue</code> in swift?</p>
  
  <p>so far I have tried:</p>
  
  <pre><code>let startIndex = attributedText.string.rangeOfString("Overdue")
  let range = startIndex..&lt;attributedText.string.finishIndex
  
  // Access the substring.
  let substring = value[range]
  print(substring)
  </code></pre>
  
  <p>But it doesn't work.</p>