how to get domain name from URL

Posted by Chinmay on Stack Overflow See other posts from Stack Overflow or by Chinmay
Published on 2009-02-20T11:01:32Z Indexed on 2010/03/23 4:11 UTC
Read the original article Hit count: 440

Filed under:
|

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:

© Stack Overflow or respective owner

Related posts about url

Related posts about regex