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);
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);
\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);