I have just started to use regular expression and I am finding it difficult to find a regular expression to get the main domain name, that is, if I have urls as given below..
url = http://blog.example.co.in/page/category=?order.php
url = https://www.example.co.ca?page.html
so out of this I want to get only the example out the urls given above. So how can i do it..!!If you can get example in any other method will also be helpful..
I myself tried some methods as given below..
var url = urls.replace('http://','').replace('https://','').replace('www.','').split(/[/?#]/)[0];
var out = url.split('.')[0];
in this I am able to get the output for
https://www.example.co.ca?page.html
but not for
url = http://blog.example.co.in/page/category=?order.php
so can someone help me out a method that can get example out of any kind url
thank you