Note that the challenge does not cover all possible valid URL constructs.
If you're going to allow dotted IPs you should really allow 32-bit IPs too, e.g., and
As such- a much simpler regex would likely 'make more people happy' than being 100% correct to tech spec.
None of those is a URI, so a URI validator most certainly should not accept them.
Anything else, and this whole exercise is a sham, because people will just write whatever works for them, or how they like it, and sacrifice "making any sense" in favour of being short ( like I did ).
The most Naïve regex I can come up with that matches (and captures) all your pasted examples so far is: I think the sane approach is to extract things that are likely to be URI's, then validate them with something stricter, I'm looking at working out how to use the browsers URI class to validate them =).