note 38292 added to function.preg-replace

From: Date: Mon, 15 Dec 2003 19:37:38 +0000
Subject: note 38292 added to function.preg-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-62005@lists.php.net to get a copy of this message
If you want the . in your pattern to include the newline character use the /s modifier at the end of your pattern. <? $string1 = "<b>text</b>"; $string2 = "<b>te\nxt</b>"; // without the s #output: something new echo preg_replace("/<b>.*<\/b>/", "something new", $string1); #output: <b>te\nxt</b> echo preg_replace("/<b>.*<\/b>/", "something more new", $string2); // with the s #output: something new echo preg_replace("/<b>.*<\/b>/s", "something new", $string1); #output: something new echo preg_replace("/<b>.*<\/b>/s", "something more new", $string2); ?> ---- Manual Page -- http://www.php.net/manual/en/function.preg-replace.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+38292 Delete -- http://master.php.net/manage/user-notes.php?action=delete+38292&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+38292&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#62005) next »