Bug #10111 Updated: e modifier alters string extraction in preg_replace

From: Date: Tue, 09 Apr 2002 21:01:50 +0000
Subject: Bug #10111 Updated: e modifier alters string extraction in preg_replace
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-4478@lists.php.net to get a copy of this message
ID: 10111 Updated by: jimw@php.net Reported By: gcousin@startem.net -Status: Open +Status: Duplicate Bug Type: PCRE related Operating System: Linux Debian PHP Version: 4.0.4pl1 New Comment: this is a duplicate of #12668 (which has more discussion about the issue, which is why i'm pointing this at the later report instead of vice versa). Previous Comments: ------------------------------------------------------------------------ [2002-03-11 09:52:22] kerry@lothrop.de This is a nice feature, not a bug. See my user contributed note in the manual under preg_replace. Maybe someone should document this behavior. ------------------------------------------------------------------------ [2001-04-02 08:08:30] gcousin@startem.net A short example : $newsitem = preg_replace('/(<([a-zA-Z-]+) ([^>]*)analyze="[0-9]*"([^>]*)>)(.*?)(<\/\\2>)/mse', "'\\1'.transformNewsitemPart('\\5').'\\6'", $newsitem); where I transform the text between any html tag with "analyze" attribute. The problem is that the preg_replace function with e modifier adds backslashes before any " in the matched text (\\5) BEFORE the function transformNewsitemPart is interpreted. The behaviour is new in php 4.0.4. It was not present in php 4.0.3. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=10111&edit=1

« previous php.bugs (#4478) next »