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

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

WBOY
Release: 2016-06-13 11:17:44
Original
1146 people have browsed it

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

代码如下,已测试通过。

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

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

else echo 'no';

?>

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template