Bug #15203 Updated: ereg_replace fails on strings containing backslashes

From: Date: Mon, 17 Jun 2002 23:00:18 +0000
Subject: Bug #15203 Updated: ereg_replace fails on strings containing backslashes
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-10964@lists.php.net to get a copy of this message
ID: 15203 Updated by: sniper@php.net Reported By: josef.svoboda@email.cz Status: Open -Bug Type: POSIX related +Bug Type: Regexps related Operating System: FreeBSD 4.2 PHP Version: 4.1.2 Previous Comments: ------------------------------------------------------------------------ [2002-04-24 09:43:06] josef.svoboda@email.cz I tried to replace sequence of two backslashes in $text by one backslash. While preg_replace works, ereg_replace does not make any change to $text. $text="\\\\"; # this string contains two backslashes echo "\n".preg_replace( "/\\\\\\\\/", "\\\\", $text); # good, prints one backslash echo "\n".ereg_replace( "\\\\\\\\", "\\\\", $text); # bad, prints two backslashes ------------------------------------------------------------------------ [2002-02-04 02:54:23] yohgaki@php.net The version of PHP that this bug was reported in is too old. Please try to reproduce this bug in the latest version of PHP (available from http://www.php.net/downloads.php If you are still able to reproduce the bug with one of the latest versions of PHP, please change the PHP version on this bug report to the version you tested and change the status back to "Open". ------------------------------------------------------------------------ [2002-01-24 06:39:57] josef.svoboda@email.cz The goal is to replace sequence of two backslashes in $text by one backslash. While preg_replace works, ereg_replace does not make any change to $text. echo "preg_replace\n"; $text="\\\\"; echo "--".$text."--".strlen($text)."\n"; $text=preg_replace( "/\\\\\\\\/", "\\\\", $text); echo "--".$text."--".strlen($text)."\n"; echo "\n"; echo "ereg_replace\n"; $text="\\\\"; echo "--".$text."--".strlen($text)."\n"; $text=ereg_replace( "\\\\\\\\", "\\\\", $text); echo "--".$text."--".strlen($text)."\n"; ./configure \ --with-mysql=/usr/local/mysql \ --with-imap=/usr/ports/new/imap \ --enable-track-vars \ --enable-trans-sid ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=15203&edit=1

« previous php.bugs (#10964) next »