Home  >  Article  >  Backend Development  >  php 正则婚配字符串为空白字符或空字符

php 正则婚配字符串为空白字符或空字符

WBOY
WBOYOriginal
2016-06-13 11:17:441129browse

php 正则匹配字符串为空白字符或空字符

代码如下,已测试通过。

$bb=' ';
$rs=preg_match("/^[\\s]*$/", $bb);

if ($rs){
echo 'yes';
}

else echo 'no';

?>

如果匹配的不包含空字符的话,就把*改成+就ok了。

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