<p>I need to test for general URLs using any protocol (http, https, shttp, ftp, svn, mysql and things I don't know about).</p>

<p>My first pass is this:</p>

<pre><code>\w+://(\w+\.)+[\w+](/[\w]+)(\?[-A-Z0-9+&amp;@#/%=~_|!:,.;]*)?
</code></pre>

<p>(<a href="http://perldoc.perl.org/perlre.html" rel="nofollow noreferrer">PCRE</a> and <a href="http://msdn.microsoft.com/en-us/library/hs600312.aspx" rel="nofollow noreferrer">.NET</a> so nothing to fancy)</p>

adding that RegEx as a wiki answer:
```
```
[\w+-]+://([a-zA-Z0-9]+\.)+[[a-zA-Z0-9]+](/[%\w]+)(\?[-A-Z0-9+&@#/%=~_|!:,.;]*)?
```
```
option 2 (Re CMS)
```
```
^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?
```
```
But that's to lax for anything sane so trimmed to make it more restrictive and to differentiate off other things.
```
```
proto      ://  name      : pass      @  server    :port      /path     ? args
^([^:/?#]+)://(([^/?#@:]+(:[^/?#@:]+)?@)?[^/?#@:]+(:[0-9]+)?)(/[^?#]*)(\?([^#]*))?
```
```