Date: 06/20/01
- Next message: derick <email protected>: "[PHP-DEV] Re: [PHP-QA] 4.0.6RC4 out."
- Previous message: Chaz: "[PHP-DEV] Re: Bug #11564 Updated: Passing variables using the GET method"
- Next in thread: oroos <email protected>: "[PHP-DEV] Bug #11540 Updated: Backslash and regular expressions"
- Maybe reply: oroos <email protected>: "[PHP-DEV] Bug #11540 Updated: Backslash and regular expressions"
- Maybe reply: andre <email protected>: "[PHP-DEV] Bug #11540 Updated: Backslash and regular expressions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
ID: 11540
User Update by: oroos <email protected>
Status: Open
Bug Type: *Regular Expressions
Operating system: Windows
PHP Version: 4.0.5
Description: Backslash and regular expressions
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
Previous Comments:
---------------------------------------------------------------------------
[2001-06-18 11:53:03] oroos <email protected>
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:
XX
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
---------------------------------------------------------------------------
Full Bug description available at: http://bugs.php.net/?id=11540
-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: derick <email protected>: "[PHP-DEV] Re: [PHP-QA] 4.0.6RC4 out."
- Previous message: Chaz: "[PHP-DEV] Re: Bug #11564 Updated: Passing variables using the GET method"
- Next in thread: oroos <email protected>: "[PHP-DEV] Bug #11540 Updated: Backslash and regular expressions"
- Maybe reply: oroos <email protected>: "[PHP-DEV] Bug #11540 Updated: Backslash and regular expressions"
- Maybe reply: andre <email protected>: "[PHP-DEV] Bug #11540 Updated: Backslash and regular expressions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

