What I want
I want to get from a URL the domain part so from http://example.com/ -> example.com>
URL
domain
http://example.com/
example.com>
There's no need to use a regex for this. PHP has an inbuilt function to do just this. Use parse_url():
$domain = parse_url($url, PHP_URL_HOST);