nlopess Sat Feb 18 22:44:06 2006 UTC
Modified files: /phpdoc/en/reference/pcre/functions preg-match.xml Log: improve last example's regex http://cvs.php.net/viewcvs.cgi/phpdoc/en/reference/pcre/functions/preg-match.xml?r1=1.19&r2=1.20&diff_format=u Index: phpdoc/en/reference/pcre/functions/preg-match.xml diff -u phpdoc/en/reference/pcre/functions/preg-match.xml:1.19 phpdoc/en/reference/pcre/functions/preg-match.xml:1.20 --- phpdoc/en/reference/pcre/functions/preg-match.xml:1.19 Fri Jun 24 09:11:45 2005 +++ phpdoc/en/reference/pcre/functions/preg-match.xml Sat Feb 18 22:44:06 2006 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.19 $ --> +<!-- $Revision: 1.20 $ --> <!-- splitted from ./en/functions/pcre.xml, last change in rev 1.2 --> <refentry id="function.preg-match"> <refnamediv> @@ -180,19 +180,17 @@ <![CDATA[ <?php // get host name from URL -preg_match("/^(http:\/\/)?([^\/]+)/i", +preg_match('@^(?:http://)?([^/]+)@i', "http://www.php.net/index.html", $matches); -$host = $matches[2]; +$host = $matches[1]; // get last two segments of host name -preg_match("/[^\.\/]+\.[^\.\/]+$/", $host, $matches); +preg_match('/[^.]+\.[^.]+$/', $host, $matches); echo "domain name is: {$matches[0]}\n"; ?> ]]> </programlisting> - <para> - This example will produce: - </para> + &example.outputs; <screen> <![CDATA[ domain name is: php.net