Regular expression meaning

Hello on a tut i c the below code

<?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];
?>

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 http://php.net/regexp.reference.subpatterns

Just to break up your regular expression further:

Delimiter
Pattern Modifier
Quantifier
Sub-pattern
Character Class
Place Holder (Meta Character)
Assertion
String to match
Anything but the following

#[1]COLOR=“#800080”?COLOR=“#800080”[/COLOR]#i


  1. /COLOR ↩︎