Document that since PHP 5.2.2, named subpatterns accept the syntax

(?<name>) and (?'name') as well as the older (?P<name>).
Addresses bug #46904.


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@288276 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Torben Wilson 2009-09-12 06:55:13 +00:00
parent d86098828a
commit 6bdd33b75f

View file

@ -174,6 +174,16 @@ Array
</row>
</thead>
<tbody>
<row>
<entry>5.2.2</entry>
<entry>
Named subpatterns now accept the
syntax <literal>(?&lt;name&gt;)</literal>
and <literal>(?'name')</literal> as well
as <literal>(?P&lt;name&gt;)</literal>. Previous versions
accepted only <literal>(?P&lt;name&gt;)</literal>.
</entry>
</row>
<row>
<entry>4.3.3</entry>
<entry>
@ -275,8 +285,12 @@ domain name is: php.net
$str = 'foobar: 2008';
// Works in PHP 5.2.2 and later.
preg_match('/(?<name>\w+): (?<digit>\d+)/', $str, $matches);
// Before PHP 5.2.2, use this:
// preg_match('/(?P<name>\w+): (?P<digit>\d+)/', $str, $matches);
print_r($matches);
?>