mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
improve last example's regex
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@207466 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
15a6d5ccd4
commit
0e8a9a7ece
1 changed files with 5 additions and 7 deletions
|
@ -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 @@ if (preg_match("/\bweb\b/i", "PHP is the website scripting language of choice.")
|
|||
<![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
|
||||
|
|
Loading…
Reference in a new issue