<?php
/*** get the host name from a url ***/
preg_match('#^(?:http://)?([^/]+)#i', "http://www.phpro.org/tutorials", $matches);
/*** show the host name ***/
echo $matches[1];
?>
That defines a non capturing group, for example in your result for $matcheshttp:// will never show up because it’s been told to match but not be returned.