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" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]