#41436 [Opn->Fbk]: e modifier doesn't go with str_replace

From: Date: Fri, 18 May 2007 16:07:12 +0000
Subject: #41436 [Opn->Fbk]: e modifier doesn't go with str_replace
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-112845@lists.php.net to get a copy of this message
ID: 41436 Updated by: tony2001@php.net Reported By: nino at recgr dot com -Status: Open +Status: Feedback Bug Type: PCRE related Operating System: Windows XP SP2 PHP Version: 5.2.2 New Comment: Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with <?php and ends with ?>, is max. 10-20 lines long and does not require any external resources such as databases, etc. If the script requires a database to demonstrate the issue, please make sure it creates all necessary tables, stored procedures etc. Please avoid embedding huge scripts into the report. Previous Comments: ------------------------------------------------------------------------ [2007-05-18 15:57:03] nino at recgr dot com Description: ------------ When I use preg_replace() with e modifier along with str_replace in the replace string, it doesn't work well. Reproduce code: --------------- HTML code ($s): <ul style="list-style-type: square;"> <li>Megadeth -- Back to the Start, Peace Sells, Rust In Peace, Countdown to Extinction </li><li>Ramones -- Anthology, Ramonesmania, Rocket to Russia, Too Tough To Die, Adios Amigos </li> </ul> $de = array('<li>', '</li>'); $s = preg_replace("#\<ul style\="list-style-type\: square;"\>(.+?)\</ul\>#sie", "'<ul style="list-style-type: square;">'.str_replace(\"$de\", '', '$1').'</ul>'", $s); Expected result: ---------------- I expect that all <li> and </li> get removed in the HTML part ($s). HOWEVER, when I turn $de to a string, so it contains <li> *or* </li>, then it works. Actual result: -------------- <li> and </li> tags don't get removed. This is also explained here (if it helps): http://forum-grounds.com/viewtopic.php?p=756 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=41436&edit=1

« previous php.bugs (#112845) next »