title: get all ranges of a substring in a string in swift
body: <p>I have a string for example "ab ad adk fda kla kad ab ab kd". I want to get all range of ab.(Here ab is present at 3 position so I should get 3 range).In normal scenarion my code is working fine, but if search text is ".",then I am getting wrong result  </p>
  
  <pre><code>do {
      let regEx = try NSRegularExpression(pattern: searchText, options: NSRegularExpressionOptions.CaseInsensitive)
  
      let matchesRanges = regEx.matchesInString(attributedText.string, options:[], range: NSMakeRange(0, attributedText.string.length))
  
      for rng in matchesRanges {
          let wordRange = rng.rangeAtIndex(0)
      }
  } catch {
      ...
  }
  </code></pre>