Hello,

I have recently posted a note on pcre.pattern.syntax.php, and I thought
you might be interested to read it, since it discusses a problem that I
feel should be addressed in the PHP docs.

Thank you,

-Eli Gordon
[EMAIL PROTECTED]
---------------------

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". 

Reply via email to