Bug #66423 [Opn->Fbk]: preg_match / preg_replace greedyness changes unpredictably with subject string

From: Date: Mon, 06 Jan 2014 03:52:35 +0000
Subject: Bug #66423 [Opn->Fbk]: preg_match / preg_replace greedyness changes unpredictably with subject string
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-183605@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66423&edit=1 ID: 66423 Updated by: requinix@php.net Reported by: publi at web dot de Summary: preg_match / preg_replace greedyness changes unpredictably with subject string -Status: Open +Status: Feedback Type: Bug Package: *Regular Expressions Operating System: Debian Linux PHP Version: Irrelevant Block user comment: N Private report: N New Comment: Increase your pcre.backtrack_limit and try again. Previous Comments: ------------------------------------------------------------------------ [2014-01-06 02:40:31] publi at web dot de Description: ------------ I am using a shared debian host where I cannot easily upgrade to a newer version of PHP myself, currently it is PHP Version 5.3.3-7+squeeze18 I currently experience the expected behavior at roughly 85% of the inputs: the preg_* modifiers "sU" make two ".*"s in the search string ungreedy. Otherwise, at least the 1st occurrence of ".*" is not greedy. Alterig it to ".*?" fixes the problem. Behavior reproducibly depended on the subject strings of the search in my tests. Since these are lengthy web pages, there is an archive with all source files at: http://omegawiki.purodha.net/test-M15/test-M15.tgz and the test script is also available to run at: http://omegawiki.purodha.net/test-M15/test-M15.php and more input files for additional tests ate at: http://omegawiki.purodha.net/test-M15/ If you want more information or additional tests, feel free to contact me via e-mail. Test script: --------------- See: http://omegawiki.purodha.net/test-M15/test-M15.tgz http://omegawiki.purodha.net/test-M15/test-M15.php Expected result: ---------------- file regex-1 regex-2 6028 1 1 6245 1 1 Actual result: -------------- file regex-1 regex-2 6028 1 1 6245 0 1 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=66423&edit=1

« previous php.bugs (#183605) next »