Skip to content

JavaScript: get domain from url with JS regex

It's as simple as url.match(/\/\/(.[^/]+)/)[1]. Requires the double slash before the domain part, but not a slash after it.