ID:               11540
 Comment by:       surgery-oral1785 at hotmail dot com
 Reported By:      oroos at fmlogistic dot pl
 Status:           Bogus
 Bug Type:         *Regular Expressions
 Operating System: Windows
 PHP Version:      4.0.5
 New Comment:

<a href=http://a4-hard-indiadownlo.da.ru>surgery oral</a>


Previous Comments:
------------------------------------------------------------------------

[2001-06-20 05:55:54] oroos at fmlogistic dot pl

Sorry my added comment is silly... I just understood why I have to put
"\\\\" in my source code and why it is enough that preg_quote generates
two backslashes...

So there is no bug at all.


------------------------------------------------------------------------

[2001-06-20 03:02:45] oroos at fmlogistic dot pl

I am told that I should put four backslahes in my pattern to make it
match a single backslash.

This is good in static patterns. But my pattern is a variable string
which I want to put in good pattern format using the fonction
preg_quote.

But this function transforms one backslash in only two backshlashes
(and not 4 !)... Thus, the only way to make my program work is to apply
two times this function preg_quote.  This works, but this is not very
nice, is it ?

So, isn't there a bug in function preg_quote ?

Thanks in advance,
Olivier Roos


------------------------------------------------------------------------

[2001-06-18 11:53:03] oroos at fmlogistic dot pl

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 this bug report at http://bugs.php.net/?id=11540&edit=1

Reply via email to