replacing chars in input
| From: | David T-G | Date: | Tue, 23 Mar 2004 16:33:48 +0000 |
| Subject: | replacing chars in input | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-181279@lists.php.net to get a copy of this message | ||
Hi, all --
I would like to make things easier for my users and replace all of the
garbage characters
`'";:~!@#$%^&*()[]{}<>/?\|+=
plus white space (\s) with underscores in the input. I am, however,
having trouble getting my regexp to work.
I can comfortably do
$i = preg_replace("/[\s]/","_",$i) ;
but trying to add other chars doesn't do a thing.
I want to end up with
A-Za-z0-9_-
(letters, numbers, underscore and dash).
If there isn't a handy character class waiting for me, what must I do to
get those chars replaced?
TIA & HAND
:-D
--
David T-G * There is too much animal courage in
(play) davidtg@justpickone.org * society and not sufficient moral courage.
(work) davidtgwork@justpickone.org -- Mary Baker Eddy, "Science and Health"
http://justpickone.org/davidtg/ Shpx gur
Pbzzhavpngvbaf Qrprapl Npg!