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

From: Date: Sat, 15 Sep 2007 19:17:30 +0000
Subject: #42678 [Opn]: reg_replace returns empty string on certain data
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-117570@lists.php.net to get a copy of this message
ID: 42678 User updated by: jana dot vasseru at gmail dot com Reported By: jana dot vasseru at gmail dot com Status: Open Bug Type: *Regular Expressions Operating System: W2000 PHP Version: 5.2.4 New Comment: The exact text file triggering the error can be found here: http://virklis.cust.ignum.cz/src.sql 163 337 byte Previous Comments: ------------------------------------------------------------------------ [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 (#117570) next »