#46904 [Com]: preg_match() example #4 is wrong
| From: | tobias382 at gmail dot com | Date: | Thu, 18 Dec 2008 20:21:25 +0000 |
| Subject: | #46904 [Com]: preg_match() example #4 is wrong | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-1647@lists.php.net to get a copy of this message | ||
ID: 46904
Comment by: tobias382 at gmail dot com
Reported By: joe at digg dot com
Status: Open
Bug Type: Documentation problem
Operating System: Debian GNU/Linux
PHP Version: Irrelevant
New Comment:
Patch for /phpdoc/en/reference/pcre/functions/preg-match.xml:
278c278
< preg_match('/(?<name>\w+): (?<digit>\d+)/', $str, $matches);
---
> preg_match('/(?P<name>\w+): (?P<digit>\d+)/', $str, $matches);
Previous Comments:
------------------------------------------------------------------------
[2008-12-18 20:08:21] joe at digg dot com
Description:
------------
On http://us.php.net/preg_match example #4 (Using named
subpattern) is
wrong. It shows:
<?php
$str = 'foobar: 2008';
preg_match('/(?<name>\w+): (?<digit>\d+)/', $str, $matches);
print_r($matches);
?>
The proper syntax for named expressions is (?P<foo>).
Expected result:
----------------
<?php
$str = 'foobar: 2008';
preg_match('/(?P<name>\w+): (?P<digit>\d+)/', $str, $matches);
print_r($matches);
?>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=46904&edit=1