I’ve modified a regex that I found here so that it would accept various UK and second-level TLDs.
/\b((?:^https?:\/\/|^[a-z0-9.\-]+[.][a-z]{2,4})(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!@()\[\]{};:'".,<>?]))/i
However as you can see in my test data here, the regex matches URLs such as www.zapple.@com and https://m!crosoft.com which are not valid.
For some reason @ symbols are excluded before the .com but after the . they are not.
Exclamation marks are not excluded at all which is confusing since, as far as I can see, only letters, numbers and dashes are allowed before the period.
The @ is matched by
And the ! mark by
I don’t know but that doesn’t look like a good regex to match url’s
Try the following which matches a url according to RFC 3986
Both absolute and relative url’sare supported.
Set case insensitivity to true
Update 1
This does not match m!crosoft.com and @pple.com It’s probably due to someting with Rublar.