From:             [EMAIL PROTECTED]
Operating system: Windows
PHP version:      4.0.5
PHP Bug Type:     *Regular Expressions
Bug description:  Backslash and regular expressions

Hello,

I have to write a program which replaces backslashes by slashes into HTML code. I 
would like to do this using regular expressions.

Unfortunately, there may be a problem in pattern matching as PHP does not seem to work 
properly as soon as I add some backslashes in my patterns...

Here is a small example which illustrates the problem:
<?
$test = "X\\X"; // $test is a string containing a backslash
echo $test."\n";
echo preg_quote($test)."\n";
echo preg_match("/X\\X/", $test)."\n";
?>

The output of this program is the following:
X\X
X\\X
0

The '0' means that the preg_match failed... But the pattern of this preg_match was the 
string $test quoted by preg_quote to become a valid pattern... (as you can see on 
second line of the output).
So this preg_match should output '1', shouldn't it ??

Thanks in advance for any help or advice,
Olivier Roos



-- 
Edit Bug report at: http://bugs.php.net/?id=11540&edit=1



-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to