#47653 [Bgs]: Error in documentation for preg_match_all
| From: | cloudyovercuba at gmail dot com | Date: | Sat, 14 Mar 2009 02:37:34 +0000 |
| Subject: | #47653 [Bgs]: Error in documentation for preg_match_all | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-1982@lists.php.net to get a copy of this message | ||
ID: 47653
User updated by: cloudyovercuba at gmail dot com
Reported By: cloudyovercuba at gmail dot com
Status: Bogus
Bug Type: Documentation problem
Operating System: Ubuntu Linux
PHP Version: Irrelevant
New Comment:
Ok. Perhaps you should make note of that in the documentation?
Previous Comments:
------------------------------------------------------------------------
[2009-03-13 23:15:32] felipe@php.net
The example is correct, it just requires PCRE 7.0, which is bundled
with PHP5.2.2+.
$ sapi/cli/php -r 'preg_match("/(?<name>\w+): (?<digit>\d+)/",
"foo:
111", $m);print_r($m);'
Array
(
[0] => foo: 111
[name] => foo
[1] => foo
[digit] => 111
[2] => 111
)
------------------------------------------------------------------------
[2009-03-13 21:01:15] cloudyovercuba at gmail dot com
Description:
------------
In the documentation for preg_match_all at
http://www.php.net/preg_match_all , example #3 shows
that a example
regex for named subpatterns is this:
/(?<name>\w+): (?<digit>\d+)/
This does not work, and returns an error. The proper regex would be
this:
/(?P<name>\w+): (?P<digit>\d+)/
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=47653&edit=1