php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48432 (?{CODE}) pattern not recognized, won't compile expression
Submitted: 2009-05-30 07:56 UTC Modified: 2009-05-30 08:34 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: webmaster at adurosolutions dot com Assigned:
Status: Not a bug Package: PCRE related
PHP Version: 5.2.9 OS: CentOs
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: webmaster at adurosolutions dot com
New email:
PHP Version: OS:

 

 [2009-05-30 07:56 UTC] webmaster at adurosolutions dot com
Description:
------------
The (?{CODE}) regular expression has been in Perl since <= 5.005, and 
the PHP documentation for PCRE says that it's current as of 5.005. This 
functionality does not appear to be functional in PHP 5.2.9.

Reproduce code:
---------------
<?

$pattern = '/^(?{ $d=0 })(?:\((?{$d++})|\)(?{$d--})(?(?{$d<0})(?!))|(?>[^()]*))*(?(?{$d!=0})(?!))$/';

$pattern_simple = '/^(?{$d=0})\(/';

$subject = '((I)(like(pie))!)';

echo "result: ".preg_match($pattern, $subject)."<br/>";

echo "result_simple: ".preg_match($pattern_simple, $subject)."<br/>";

?>

Expected result:
----------------
I'm not claiming that the regular expressions should produce a match, 
but they should compile and be evaluated, and thus return either a 0 or 
a 1.

Actual result:
--------------
Warning: preg_match() [function.preg-match]: Compilation failed: 
unrecognized character after (? or (?- at offset 2 in __FILE__ on line 
__LINE__

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-05-30 08:34 UTC] scottmac@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

The manual clearly states we don't support this.

Fairly obviously, PCRE does not support the (?{code}) and (??{code}) construction. However, there is support for recursive patterns.
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Thu May 19 06:05:44 2022 UTC