|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2001-06-20 03:02 UTC] oroos at fmlogistic dot pl
[2001-06-20 05:55 UTC] oroos at fmlogistic dot pl
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 09:00:02 2025 UTC |
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