Home  >  Article  >  Backend Development  >  正则过滤全角空格解决方案

正则过滤全角空格解决方案

WBOY
WBOYOriginal
2016-06-13 11:10:221144browse

正则过滤全角空格
请问哪位有试过用正则过滤掉空格,要包括全角的。


------解决方案--------------------
转换成UTF-8,加u修正符
$s='ad sf中 ds';
echo preg_replace('/[  ]+/u','',$s);
------解决方案--------------------
\s 匹配任何空白字符,包括空格、制表符、换页符等等。等价于 [ \f\n\r\t\v]。
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn