开发者

Enable whitespace in php regular expresssion

I want to have A-Z, 0-9 and whitespace ignored in regular expression, currently I have this, it works but whitespaces are ignored开发者_StackOverflow 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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜