views:

19

answers:

1

I want to have A-Z, 0-9 and whitespace ignored in regular expression, currently I have this, it works but whitespaces are ignored too but I need them.

preg_match_all("/[^\w]/",$string,$matches);
+1  A: 

\s represents whitespace characters. So if you want to match every character except word characters (\w) or whitespace characters (\s), try this:

preg_match_all("/[^\w\s]/",$string,$matches);
Gumbo
thanks it works! I know that s is for that but I've put the s outside of the bracket lol :D thanks very much! But I have another problem I will edit my post.
CIRK
@Cirk: What is part one and what the other part(s)?
Gumbo
:D I've posted another question http://stackoverflow.com/questions/3174338/php-regex-ignore-and
CIRK
@Cirk: Why don’t you ask just one question?
Gumbo
Well I wanted first, but I think it's better to make a new question for that.
CIRK