#42678 [Opn->Bgs]: reg_replace returns empty string on certain data

From: Date: Sat, 15 Sep 2007 19:31:32 +0000
Subject: #42678 [Opn->Bgs]: reg_replace returns empty string on certain data
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-117572@lists.php.net to get a copy of this message
ID: 42678 Updated by: scottmac@php.net Reported By: jana dot vasseru at gmail dot com -Status: Open +Status: Bogus Bug Type: *Regular Expressions Operating System: W2000 PHP Version: 5.2.4 New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Check preg_last_error() you've probably hit one of the limits to stop you smashing the stack. Previous Comments: ------------------------------------------------------------------------ [2007-09-15 19:17:29] jana dot vasseru at gmail dot com The exact text file triggering the error can be found here: http://virklis.cust.ignum.cz/src.sql 163 337 byte ------------------------------------------------------------------------ [2007-09-15 19:15:07] jana dot vasseru at gmail dot com Description: ------------ On certain data preg_replace() returns empty string. The code below works correctly on PHP 5.1.6 Reproduce code: --------------- <?php $data = file_get_contents('src.sql'); echo strlen($data).'<br>'; $data = preg_replace("#INSERT\\sINTO([\\s\\S]*?)INSERT\\sINTO#", "\$DELTA_SCRIPT[] = 'INSERT INTO\\1'; \$DELTA_SCRIPT[] = 'INSERT INTO", $data); $data = preg_replace("#CREATE\\sTABLE([\\s\\S]*?)[^']INSERT\\sINTO#", "CREATE TABLE \\1 \$DELTA_SCRIPT[] = 'INSERT INTO", $data); echo strlen($data); //returns 0 here ?> Expected result: ---------------- Return whatever but empty string. Actual result: -------------- Returns empty string. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=42678&edit=1

« previous php.bugs (#117572) next »