请问正则匹配,有个小疑惑

WBOY
Release: 2016-06-13 12:01:30
Original
818 people have browsed it

请教正则匹配,有个小疑惑

<br /><?php<br />$str='唐老鸭'; //老,唐老鸭等有老字的都不能通过<br />$pre='/[\'\"\ \ ]/'; //把全角空格去掉就可以<br />if(preg_match($pre, $str)){<br />	echo $str.'不通过';<br />}<br />else{<br />	echo $str.'通过';<br />}<br />?><br />
Copy after login

求解,谢谢。
------解决方案--------------------
指定一下编码
$pre='/[\'\"\ \ ]/u';
Copy after login

------解决方案--------------------
$str='唐老鸭'; <br />$pre='/[\'\"\ \ ]/';<br />if(preg_match($pre, $str)){<br />    echo $str.'不通过';<br />}<br />else{<br />    echo $str.'通过';<br />}
Copy after login
唐老鸭通过
$str='唐老 鸭'; <br />$pre='/[\'\"\ \ ]/';<br />if(preg_match($pre, $str)){<br />    echo $str.'不通过';<br />}<br />else{<br />    echo $str.'通过';<br />}
Copy after login
唐老 鸭不通过

不知道你要做什么

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