Answer:
The simplest way is to add prototype to string object and use regular expression inside prototype function as following:
String.prototype.getHostName = function() {
var str = this;
var re = new RegExp('^(?:f|ht)tp(?:s)?://([^/?]+)', 'im');
return str.match(re)[0].toString();
}
The simplest way is to add prototype to string object and use regular expression inside prototype function as following:
String.prototype.getHostName = function() {
var str = this;
var re = new RegExp('^(?:f|ht)tp(?:s)?://([^/?]+)', 'im');
return str.match(re)[0].toString();
}