I trying to create a regex that can extract the base domains from various lines of strings that may contain 1 or multiple domains e.g.
http://www.website1.com/forum/register.phpdo=deleteactivation&u=434543543545443
http://mywebsite.com/?url=referralwebsite.com&id=id24
should return:
website1.com
mywebsite.com
referralwebsite.com
I have an expression that seems to work (but only returns the first domain in a line):
([\w-]+\.)+[a-zA-Z]{2,4}+(?![a-zA-Z])
It would be nice to keep it clean of other strings that end with 3 letter extensions like register.php but that is not required. It would also be good to keep it as simple and fast as possible.
Also it should be able to sub domains and country specific domains e.g. mysubdomain.website.co.uk, Any ideas?