I need a regEx to match general URLs

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

My first pass is this:

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

(PCRE and .NET so nothing to fancy)

Answers


According to RFC2396:

^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?

Need Your Help

problem with RewriteRule and apache

apache mod-rewrite

I have a SSL certificate that is registered to my www domain, but all my urls point to my domain without www.