title: Swift extract regex matches
body: <p>I want to extract substrings from a string that match a regex pattern. </p>
  
  <p>So I'm looking for something like this:</p>
  
  <pre><code>func matchesForRegexInText(regex: String!, text: String!) -&gt; [String] {
     ???
  }
  </code></pre>
  
  <p>So this is what I have:</p>
  
  <pre><code>func matchesForRegexInText(regex: String!, text: String!) -&gt; [String] {
  
      var regex = NSRegularExpression(pattern: regex, 
          options: nil, error: nil)
  
      var results = regex.matchesInString(text, 
          options: nil, range: NSMakeRange(0, countElements(text))) 
              as Array&lt;NSTextCheckingResult&gt;
  
      /// ???
  
      return ...
  }
  </code></pre>
  
  <p>The problem is, that <code>matchesInString</code> delivers me an array of <code>NSTextCheckingResult</code>, where <code>NSTextCheckingResult.range</code> is of type <code>NSRange</code>. </p>
  
  <p><code>NSRange</code> is incompatible with <code>Range&lt;String.Index&gt;</code>, so it prevents me of using <code>text.substringWithRange(...)</code></p>
  
  <p>Any idea how to achieve this simple thing in swift without too many lines of code?</p>