I am having a problem with regular expression for getting the main domain name from a url. that is if i am having urls as given below..
http://domain.com/return/java.php?hello.asp
http://www.domain.com/return/java.php?hello.asp
http://blog.domain.net/return/java.php?hello.asp
http://us.blog.domain.co.us/return/java.php?hello.asp
http://domain.co.uk
http://domain.net
http://www.blog.domain.co.ca/return/java.php?hello.asp
http://us.domain.com/return/
from all this I should only get domain as the output of the regular expression.. so how do i do it? i used;
var url = urls.match(/[^.]*.(com|net|org|info|coop|int|co\.uk|org\.uk|ac\.uk|uk)/g);
but it does not work for
http://domain.net
so can someone help me out with this.
.since it is a special character, after the[^.]*part. :)