note 37077 added to function.preg-replace
| From: | Peter at rn2 dot php dot net | Date: | Sat, 01 Nov 2003 22:00:51 +0000 |
| Subject: | note 37077 added to function.preg-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-59645@lists.php.net to get a copy of this message | ||
Suppose you want to match '\n' (that's backslash-n, not newline). The pattern you
want is not /\\n/ but /\\\\n/. The reason for this is that before the regex engine can interpret the
\\ into \, PHP interprets it. Thus, if you write the first, the regex engine sees \n, which is reads
as newline. Thus, you have to escape your backslashes twice: once for PHP, and once for the regex
engine.
----
Manual Page -- http://www.php.net/manual/en/function.preg-replace.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+37077
Delete -- http://master.php.net/manage/user-notes.php?action=delete+37077&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+37077&report=yes
Search -- http://master.php.net/manage/user-notes.php