As an addentum to @amon's excellent answer:
The Expression Library of the Expresso RegEx tool has this pattern for URL's (C# syntax):
(?<Protocol>\w+):\/\/(?<Domain>[\w@][\w.:@]+)\/?[\w\.?=%&=\-@/$,]*
Putting it against @amon's test cases yields these results:

Stuff in parentheses isn't captured, nor IPV6 IP's. But I'd consider it a good starting point with fewer false positives, and it also matches all the common URL's in this question.
Now your pattern doesn't match any of the URL's I've tested with that tool, and the above regex pattern certainly wouldn't work in JavaScript. Removing the named capture groups gives this (untested):
\w+:\/\/[\w@][\w.:@]+\/?[\w\.?=%&=\-@/$,]*
Some ideas:
- Use numbered capture groups to distinguish the URL parts. It makes it a little easier to debug a regular expression that doesn't do what it's supposed to be doing.
- Depending on how the result is used, I would also add a group that captures the query string independently, if the URL has one.