Re: ereg(_replace) help
| From: | rasmus at lerdorf dot on dot ca | Date: | Fri, 21 Jul 2000 21:58:35 +0000 |
| Subject: | Re: ereg(_replace) help | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-7637@lists.php.net to get a copy of this message | ||
Would be easier to use:
$new = ereg_replace("[^[:alnum:][:punct:]]","",$str);
Check the regex.7 man page in the regex dir of the PHP distibution source
code.
-Rasmus
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.
>
> Monte
>
> Ed Vul wrote:
> >
> > Uhm... I need to remove every funky character from a string except for
> > alphanumeric, and punctuation ... how would I do that.
> > I know I use erg_replace, but i don't know how to use that...
> > Can someone point me to a regexp tutorial somewhere?
> >
> > Thanks
> > Ed
> >
> > --
> > 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
>
> --
> Monte Ohrt <monte@ispi.net>
> http://www.ispi.net/
>
>