title: Extract links from string optimization
body: <p>I get data (HTML string) from website. I want to extract all links. I write function (it works), but it is so slow... </p>
  
  <p>Can you help me to optimize it? What standard functions I can use? 
  Function logic: find "http:.//" sting in text, and then read string (buy char) until I will not get "\"".</p>
  
  <pre><code>extension String {
  
  subscript (i: Int) -&gt; Character {
      return self[advance(self.startIndex, i)]
  }
  
  subscript (i: Int) -&gt; String {
      return String(self[i] as Character)
  }
  
  subscript (r: Range&lt;Int&gt;) -&gt; String {
      return substringWithRange(Range(start: advance(startIndex, r.startIndex), end: advance(startIndex, r.endIndex)))
  }}
  
  
  
  func extractAllLinks(text:String) -&gt; Array&lt;String&gt;{
  var stringArray = Array&lt;String&gt;()
  var find = "http://" as String
  
  for (var i = countElements(find); i&lt;countElements(text); i++)
  {
      var ch:Character = text[i - Int(countElements(find))]
      if (ch == find[0])
      {
          var j = 0
          while (ch == find[j])
          {
              var ch2:Character = find[j]
              if(countElements(find)-1 == j)
              {
                  break
              }
              j++
              i++
              ch = text[i - Int(countElements(find))]
          }
  
          i -= j
          if (j == (countElements(find)-1))
          {
              var str = ""
              for (; text[i - Int(countElements(find))] != "\""; i++)
              {
                  str += text[i - Int(countElements(find))]
              }
              stringArray.append(str)
          }
  
      }
  }
  return stringArray}
  </code></pre>