php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #50306 preg_match_all() example #3 is wrong
Submitted: 2009-11-26 06:55 UTC Modified: 2009-12-17 12:30 UTC
From: kalle dot v at kolumbus dot fi Assigned: seld (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: Red Hat
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: kalle dot v at kolumbus dot fi
New email:
PHP Version: OS:

 

 [2009-11-26 06:55 UTC] kalle dot v at kolumbus dot fi
Description:
------------
Similar to Bug #46904 preg_match() example #4 is wrong (http://bugs.php.net/bug.php?id=46904), but with preg_match_all.

Seems the original issue discussed in the comments of bug #46904 is not actually related only to PHP version. I have a Red Hat box with PHP 5.2.6 installed but still this doesn't work: (?<name>\w+) and this works: (?P<name>\w+)

And I had some trouble figuring this one out, since I use preg_match_all and in the preg_match_all documentation example #3 is similar to the one that was previously in preg_match example #4. And named subpatterns was something I hadn't used before, so I didn't know about the different syntaxes. So I think at least the same comment that was added to preg_match should be added to preg_match_all documentation so people will know there are these different syntaxes and they can try them out if they get errors.

But maybe someone should check this again to find out what actually makes these different syntaxes work with different PHP versions/machines/operating systems.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-12-17 12:28 UTC] svn@php.net
Automatic comment from SVN on behalf of seld
Revision: http://svn.php.net/viewvc/?view=revision&revision=292248
Log: Emphasize the use of ?P<> for named sub-patterns instead of the backwards incompatible ?<>. Fixes bug #50306 - refs bug #46904
 [2009-12-17 12:30 UTC] seld@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation
better.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Jun 17 13:08:35 2026 UTC