I also mentioned RFC 3986, but it's too general, as it is designed to map relative URLs. Obviously, in the case of OP, we want absolute public URLs.
Something like ^(https?://)?(?:[\w.]+)\.(?:[\w:.]+) seems more realistic. I intentionally exclude sites requiring a username / password pair, but accept the port number.
Such an expression will be broken when Unicode URLs are common ...
[EDIT] I accepted any scheme, I have to limit more, I suppose, I donβt need to accept ftp addresses or bzr + ssl: // for an open case ...
source share