note 42281 added to function.preg-replace
| From: | rolfhub at gmx dot net | Date: | Tue, 11 May 2004 00:17:50 +0000 |
| Subject: | note 42281 added to function.preg-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-69433@lists.php.net to get a copy of this message | ||
What is not stated in the manual (at least i didn't find it anywhere) is that you have to
enclose the pattern in slashes, so for example this will not work:
<?php
preg_replace("<\/[^>]+>", "\\0\n", $htmlcode);
?>
But this will do the job:
<?php
preg_replace("/<\/[^>]+>/", "\\0\n", $htmlcode);
?>
A primitive example, just to make the point:
<?php
preg_replace("french fries", "freedom fries", $food);
?>
will not do, you have to write:
<?php
preg_replace("/french fries/", "freedom fries", $food);
?>
----
Manual Page -- http://www.php.net/manual/en/function.preg-replace.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+42281
Delete -- http://master.php.net/manage/user-notes.php?action=delete+42281&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+42281&report=yes
Search -- http://master.php.net/manage/user-notes.php