Re: Arrrr The Space is gone.
| From: | CC Zona | Date: | Sun, 27 Jan 2002 05:15:12 +0000 |
| Subject: | Re: Arrrr The Space is gone. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-82269@lists.php.net to get a copy of this message | ||
In article <002801c1a6ed$1a9c10a0$0401a8c0@philip>,
newmanpj@philipsdomain.com (Philip J. Newman) wrote:
> $q=preg replace("/[ \W]/","",$q);
>
> I have this to remove all the bad things, but it takes out the space to ...
> )o; why?
There's a space in your character class, so of course it will be among the
characters matched/replaced. But merely deleting it from the character
class doesn't solve the problem either, since a space character also meets
the criteria for "not a word character" (\W). If the objective is to strip
all characters that are neither a space nor a "word" (a-zA-Z0-9_), then try:
$q=preg replace("/[^ \w]/","",$q);
--
CC