Capture the domain till the ending characters $, \\?, /, :
. I need a regex that captures domian.com
in all of these.
domain.com:3000
do
Since you're using node, just use the built-in url.parse()
method; you want the resulting hostname
property:
var url=require('url');
var urls = [
'http://domain.com:3000',
'http://domain.com?pass=gas',
'http://domain.com/',
'http://domain.com'
];
UPDATED:
urls.forEach(function(x) {
console.log(url.parse(x).hostname);
});