php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #62237 PCRE recursion pattern should be (?&name), not (?P&name)
Submitted: 2012-06-06 05:37 UTC Modified: 2012-06-07 17:38 UTC
From: danielklein at airpost dot net Assigned: felipe (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.4.3 OS:
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: danielklein at airpost dot net
New email:
PHP Version: OS:

 

 [2012-06-06 05:37 UTC] danielklein at airpost dot net
Description:
------------
Including (?P&name) in a pattern (as described on http://www.php.net/manual/en/regexp.reference.recursive.php) causes an error. Changing it to (?P>name) or (?&name) works as expected (see http://perldoc.perl.org/perlre.html#PCRE%2fPython-Support and elsewhere on the same page). The reference to (?P&name) needs to be changed to (?&name).

Test script:
---------------
<?php
var_export(preg_match('/(?<foo>a)(?P>foo)/', 'aa')); // Good
print("\n");
var_export(preg_match('/(?<foo>a)(?&foo)/', 'aa')); // Good
print("\n");
var_export(preg_match('/(?<foo>a)(?P&foo)/', 'aa')); // Bad
?>


Actual result:
--------------
1
1
Warning:  preg_match(): Compilation failed: unrecognized character after (?P at offset ...

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-06-07 17:38 UTC] felipe@php.net
Automatic comment from SVN on behalf of felipe
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=326014
Log: - Fixed bug #62237 (PCRE recursion pattern should be (?&amp;name), not (?P&amp;name))
 [2012-06-07 17:38 UTC] felipe@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.


 [2012-06-07 17:38 UTC] felipe@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: felipe
 [2020-02-07 06:08 UTC] phpdocbot@php.net
Automatic comment on behalf of felipe
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=33f6eda0cd1238cd3ee1d5608784639f46a51dc8
Log: - Fixed bug #62237 (PCRE recursion pattern should be (?&amp;name), not (?P&amp;name))
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Oct 08 11:00:02 2026 UTC