How can I fetch a domain name from a URL String?
Examples:
+----------------------+------------+ | input | output | +----------------------+------------+ | www.google.com | google | | www.mail.yahoo.com | mail.yahoo | | www.mail.yahoo.co.in | mail.yahoo | | www.abc.au.uk | abc | +----------------------+------------+
Related:
I once had to write such a regex for a company I worked for. The solution was this:
Example regex:
This worked really well and also matched weird, unofficial top-levels like de.com and friends.
The upside:
The downside of this solution is of course: