Regular expression meaning

Hello on a tut i c the below code

        /*** get the host name from a url ***/
        preg_match('#^(?:http://)?([^/]+)#i', "", $matches);

        /*** show the host name ***/
        echo $matches[1];

What’s the meaning of


That defines a non capturing group, for example in your result for $matches http:// will never show up because it’s been told to match but not be returned.

Thank you. I appreciate it

Fuller details can be found in the PHP manual at

Just to break up your regular expression further:

Pattern Modifier
Character Class
Place Holder (Meta Character)
String to match
Anything but the following


  1. /COLOR ↩︎