note 37077 deleted from function.preg-replace by colder
| From: | colder@php.net | Date: | Mon, 18 Jun 2007 19:49:46 +0000 |
| Subject: | note 37077 deleted from function.preg-replace by colder | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-127666@lists.php.net to get a copy of this message | ||
Note Submitter: Peter
----
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.