note 38292 deleted from function.preg-replace by tularis
| From: | tularis@php.net | Date: | Sun, 18 Jun 2006 13:16:32 +0000 |
| Subject: | note 38292 deleted from function.preg-replace by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-114299@lists.php.net to get a copy of this message | ||
Note Submitter: kweejee at clan-zzq dot org
----
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);
?>