note 55294 added to function.preg-replace

From: Date: Fri, 29 Jul 2005 11:05:54 +0000
Subject: note 55294 added to function.preg-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-92722@lists.php.net to get a copy of this message
Replacing a double quote in a string using the /e modifier in preg_replace() returns a backslash. $string='\'"'; echo preg_replace('/(["\'])/ie', '"[".ord(\'$1\')."]"', $string); Exprected result: [39][34] Result: [39][92] So the double quote is prepended by a backslash. A workaround is : echo preg_replace('/(["\'])/ie', '"[".ord(substr(\'$1\',-1))."]"', $string); which returns the desired result for the double quote as well. ---- Submitter IP: 64.246.30.37 ---- Manual Page -- http://www.php.net/manual/en/function.preg-replace.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+55294 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55294&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55294&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55294&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55294&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55294&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55294&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+55294&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#92722) next »