Re: removing double backslashes and leaving singles

From: Date: Tue, 22 May 2001 16:20:39 +0000
Subject: Re: removing double backslashes and leaving singles
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-53877@lists.php.net to get a copy of this message
Don't forget you need to escape the backslashes both for PHP and the regular expression engine. So, if you want to match \\, you need \\\\ to escape for php, then escape them both again for regex \\\\\\\\. \\\\ matches just one real backslash :) adamw ----- Original Message ----- From: "Dennis Gearon" <gearond@oit.edu> To: <php-general@lists.php.net> Sent: Tuesday, May 22, 2001 5:10 PM Subject: [PHP] removing double backslashes and leaving singles > I've tried this and it doesn't work, any ideas? > > $illegal_chars="[^a-zA-Z0-9._\\:]|\\\\"; > $dir="c:\\t.e.s.t.\\\\7."; > $dir_name = ereg_replace($illegal_chars, "", $dir_name); > > it removes the single double slash after :, as well. > > this is on version 4.0.3pl1 > > would some people please test this on their boxes/versions? > > I tried preg_replace(), and it did the same thing. I don't think it > should remove that single backslash, right? > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.general (#53877) next »