there is country code in url which i need to extract by regex and javascript.
so my possible url would be
http://example.com/gb/index.aspx
http://localhost:2020/gb/index.aspx
http://example:2020/gb/index.aspx
these code i tried but regex works for a specific type of url.
var url = "http://example.com/gb/index.aspx";
//Get the language code
var countrycode = /com\/([^\/]+)/.exec(url)[1];
the above code works when url look like http://example.com/gb/index.aspx but the moment url look like http://localhost:2020/gb/index.aspx or http://example:2020/gb/index.aspx then above code does not works. so tell me which regex i need to use which can extract country code from above 3 different kind of url. need some hint. thanks