title: Regular expression to match generic URL
body: <p>I've looked all over and have yet to find a single solution to address my need for a regular expression pattern that will match a generic URL.  I need to support multiple protocols (with verification), localhost and/or IP addressing, ports and query strings.  Some examples:</p>
  
  <ul>
  <li><a href="http://localhost/mysite" rel="nofollow">http://localhost/mysite</a></li>
  <li><a href="https://localhost:55000" rel="nofollow">https://localhost:55000</a></li>
  <li><a href="ftp://192.1.1.1" rel="nofollow">ftp://192.1.1.1</a></li>
  <li>telnet://somesite/page.htm?a=1&amp;b=2</li>
  </ul>
  
  <p>Ideally, I'd like the pattern to also support extracting the various elements (protocol, host, port, query string, etc.) but this is not a requirement.</p>
  
  <p>(Also, for the purposes of myself and future readers, if you could explain the pattern, it would be helpful.)</p>