ID: 14893
Updated by: sterling
Reported By: [EMAIL PROTECTED]
Old Status: Open
Status: Bogus
Bug Type: PCRE related
Operating System: SunOS
PHP Version: 4.1.1
New Comment:

a) Not a PHP bug (but its good to be aware of this issue, if you
wouldn't mind please send a mail to [EMAIL PROTECTED] with any updates,
etc.)

b) not sure if this is really a bug, the way I read the 1st regex is:

read in ab
put that as \1
after a digit match \1
which is ab
after the digit there is only b

whereas in the second example you make the regex non-greedy, so
therefore it matches from the beginning of the string and matches the
ab from the lookahead assertion.

I could be wrong, but either way its not a PHP bug ;)  If you disagree
please follow up at [EMAIL PROTECTED]

regards,
sterling


Previous Comments:
------------------------------------------------------------------------

[2002-01-06 17:57:14] [EMAIL PROTECTED]

Here's the problem:

<? echo preg_match('/(.*)\d+\1/', 'ab1b'); ?>

It fails, but it really shouldn't.  You can fool the engine into not
having the bug:

<? echo preg_match('/(?=)(.*)\d+\1/', 'ab1b'); ?>

The bug is thus:  a regex that starts with .* can logically be made to
start with an implicit anchor to the beginning of the string.  However,
this optimization can break the success of a regex if the .* is
captured (as above) and used later (the back-reference \1).  I've
contacted the author of the PCRE package.

------------------------------------------------------------------------



Edit this bug report at http://bugs.php.net/?id=14893&edit=1


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to