title: swift - substring from string
body: <p>I have some of url string like:</p>
  
  <p>let url1 = "<a href="https://abc/help?user_info_id=5#help-article03" rel="nofollow">https://abc/help?user_info_id=5#help-article03</a>"</p>
  
  <p>let url2 = "<a href="https://cde?user_info_id=455&amp;artical=4">https://cde?user_info_id=455&amp;artical=4</a>"</p>
  
  <p>let url3 = "<a href="https://ghi/help?user_info_id=5" rel="nofollow">https://ghi/help?user_info_id=5</a>"</p>
  
  <p>Now i want to get user_info_id from these urls.</p>
  
  <p>url1 return 5, url2 return 455 and url3 return 5</p>
  
  <p>This is my code</p>
  
  <pre><code>func getID(string: String) -&gt; String {
      let range = string.rangeOfString("user_info_id=")
      guard let endIndex = range?.endIndex else { return "" }
      let remain = string.substringFromIndex(endIndex)
  
      let num = "0123456789"
      var result = ""
      for c in remain.characters {
          if num.containsString(String(c)) {
              result.append(c)
          } else {
              break
          }
      }
      return result
  }
  </code></pre>
  
  <p>Please tell me your idea. Thank you!</p>