【问一个正则表达式有关问题】

WBOY
Release: 2016-06-13 13:10:07
Original
899 people have browsed it

【问一个正则表达式问题】
问题描述:
禁止全字母;
禁止全数字;
禁止特殊字符;
禁止标点符号;
长度2到7个字符;


如果上面的比较难可以直接写下面的

只允许中文字符串;
长度在2到7个字符;
禁止特殊字符;
禁止标点符号;




------解决方案--------------------
简而言之,就是要匹配一个2-7个字的中文字符串呗
------解决方案--------------------
其实这个问题百度可以找的到,下面是引用的代码:
$str = "php编程";
if (preg_match("/^[\x{4e00}-\x{9fa5}]+$/u",$str)) {
print("该字符串全部是中文");
} else {
print("该字符串不全部是中文");
}
------解决方案--------------------
长度自己加个字符集转换然后判断相应的长度就可以了

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!