开发者

Enable whitespace in php regular expresssion

开发者 https://www.devze.com 2023-01-05 10:54 出处:网络
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.

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

精彩评论

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

关注公众号