Re: ereg(_replace) help
| From: | Monte Ohrt | Date: | Fri, 21 Jul 2000 21:54:28 +0000 |
| Subject: | Re: ereg(_replace) help | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-7636@lists.php.net to get a copy of this message | ||
Ok, I was being lazy. You can look up what has to be escaped if you wish
;-)
Andrei Zmievski wrote:
>
> On Fri, 21 Jul 2000, Monte Ohrt wrote:
> > I think I know the syntax for preg_replace(). You include everything in
> > a character class [], and the leading ^ means a logic NOT.
> >
> > $string =
> >
> > preg_replace("/[^\w\d\+\!\@\#\$\%\^\&\*\(\)\[\]\{\}\\\|\;\:\'\"\,\.\<\>\/\?\+\=\~\`\_\-]+/","",
> > $string);
> >
> > \w = word character
> > \d = digit
> >
> > everything else is literal. Include each one you wan to keep, and make
> > sure \- is last in the character class.
>
> You don't need to backslash everything...
>
> -Andrei
>
> Nobody tried to design Windows - it just grew in random
> directions without any kind of thought behind it.
--
Monte Ohrt <monte@ispi.net>
http://www.ispi.net/