note 42281 deleted from function.preg-replace by aidan
| From: | aidan@php.net | Date: | Tue, 07 Dec 2004 03:13:44 +0000 |
| Subject: | note 42281 deleted from function.preg-replace by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-81467@lists.php.net to get a copy of this message | ||
Note Submitter: rolfhub at gmx dot net
----
[Editors Note:
Actually you have to enclose it in ANY preg delimiter, for example:
@regex@
~regex~
{regex}
#regex#
]
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);
?>