#42806 [Opn->Bgs]: preg_replace returns empty string
| From: | scottmac@php.net | Date: | Mon, 01 Oct 2007 09:11:15 +0000 |
| Subject: | #42806 [Opn->Bgs]: preg_replace returns empty string | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-118000@lists.php.net to get a copy of this message | ||
ID: 42806
Updated by: scottmac@php.net
Reported By: jm at mayfirst dot org
-Status: Open
+Status: Bogus
Bug Type: PCRE related
Operating System: gnu linux/debian sid
PHP Version: 5.2.4
New Comment:
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.
Within the loop if $count equals 0 you exit without calling
preg_last_error();
If you had a preg_last_error call there you get int(2) which means
PREG_BACKTRACK_LIMIT_ERROR
Previous Comments:
------------------------------------------------------------------------
[2007-10-01 01:00:29] jm at mayfirst dot org
Description:
------------
When executing preg_replace on a string over 32,205 bytes and no double
line breaks with the following expression, the function neither matches
nor returns the original string. preg_last_error() doesn't indicate any
preg related errors.
Reproduce code:
---------------
error_reporting(E_ALL);
$original_string = "This is a preg_replace bug.\n";
$string = '';
$i = 0;
while($i < 1177) {
$string .= $original_string;
preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "foo",
$string,-1,$count);
if($count == 0) {
echo "I broke at count: $i\n";
exit;
}
$i++;
}
echo "I didn't break at count: $i\n";
echo preg_last_error();
Expected result:
----------------
I didn't break at count: 1176.
Actual result:
--------------
I broke at count: 1176
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=42806&edit=1