note 36602 deleted from pcre.pattern.syntax by didou

From: Date: Thu, 16 Oct 2003 08:18:02 +0000
Subject: note 36602 deleted from pcre.pattern.syntax by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-58682@lists.php.net to get a copy of this message
Note Submitter: eli.gordon@no__spam.care2.spamcom ---- According to this doc: : if you want to match a backslash, you write "\\". This does not seem to be the case. In fact, you need three backslashes ("\\\"), not just two. For example, let's say we want to replace all instances of "\b" in the string "foo \b" with the word "bar": preg_replace('/\\b/', 'bar', 'foo \b'); returns: "barfoobar \barbbar" preg_replace('/\\\b/', 'bar', 'foo \b'); returns what we expect: "foo bar" I imagine what happens here is that the double-backslash is translated into a single backslash character, as it is supposed to, but then the resulting "\b" is again evaluated, leaving us with just the letter "b".

« previous php.notes (#58682) next »