ID: 49550
Updated by: [email protected]
Reported By: spoon dot reloaded at gmail dot com
Status: Bogus
Bug Type: PCRE related
Operating System: Linux
PHP Version: 5.3.0
New Comment:
The only time a PCRE pattern related report like this should be
submitted as a PHP bug is if you can prove it works in the command line
pcre debugging tool, but it breaks in PHP. Otherwise you should be
reporting stuff like this to the PCRE project.
Previous Comments:
------------------------------------------------------------------------
[2009-09-14 11:14:23] spoon dot reloaded at gmail dot com
oops my previous workaround still doens't work
echo preg_match('/^$|^(.(?:|(?1)))$/', 'abc'), "\n";
------------------------------------------------------------------------
[2009-09-14 11:05:33] spoon dot reloaded at gmail dot com
oops in that last one I meant
echo preg_match('/^$|^(.(?:|(?1)))$/', 'ab'), "\n";
------------------------------------------------------------------------
[2009-09-14 10:58:29] spoon dot reloaded at gmail dot com
I found a solution:
echo preg_match('/^|(.(?:|(?1)))$/', 'ab'), "\n";
but I still don't understand why the other one doesn't work
------------------------------------------------------------------------
[2009-09-14 10:49:09] spoon dot reloaded at gmail dot com
But that still wouldn't explain why stuff like balanced parentheses
matching /^(\(((?>[^()]+)|(?1))*\))$/ works. I am still waiting for an
explanation on my example.
------------------------------------------------------------------------
[2009-09-14 10:24:41] spoon dot reloaded at gmail dot com
Nevermind, so I think the reason is that PCRE differs from Perl in that
a recursive "sub-"pattern (i.e. ?1, ?2, etc. but not ?0) only matches
exactly what was matched before by that subgroup, even if there are
other unused possibilities by that group. Is that correct?
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/49550
--
Edit this bug report at http://bugs.php.net/?id=49550&edit=1