There is no perfect URL validation regex, because there are so many things you can do with URLs, and so many contexts to use them with. So, it might be perfect for the OP, but completely inappropriate for you.<p>That said, there is a regex in RFC3986, but that's for parsing a URI, not validating it.<p>I converted 3986's ABNF to regex here:
<a href="https://gist.github.com/mnot/138549" rel="nofollow">https://gist.github.com/mnot/138549</a><p>However, some of the test cases in the original post (the list of URLs there aren't available separately any more :( ) are IRIs, not URIs, so they fail; they need to be converted to URIs first.<p>In the sense of the WHATWG's specs, what he's looking for <i>are</i> URLs, so this could be useful:
<a href="http://url.spec.whatwg.org" rel="nofollow">http://url.spec.whatwg.org</a><p>However, I don't know of a regex that implements that, and there isn't any ABNF to convert from there.