mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
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:
parent
d86098828a
commit
6bdd33b75f
1 changed files with 14 additions and 0 deletions
|
@ -174,6 +174,16 @@ Array
|
|||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>5.2.2</entry>
|
||||
<entry>
|
||||
Named subpatterns now accept the
|
||||
syntax <literal>(?<name>)</literal>
|
||||
and <literal>(?'name')</literal> as well
|
||||
as <literal>(?P<name>)</literal>. Previous versions
|
||||
accepted only <literal>(?P<name>)</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);
|
||||
|
||||
?>
|
||||
|
|
Loading…
Reference in a new issue