Home > php教程 > PHP源码 > php正则中文表达式

php正则中文表达式

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-08 17:25:32
Original
1035 people have browsed it
<script>ec(2);</script>

php教程正则中文表达式
$str = "abc一二三cde";
echo preg_replace('/[^x4e00-x9fa5]/i'," ",$str);

$str = "php编程";
if (preg_match("/^[x4e00-x9fa5]+$/u",$str)) {
print("该字符串全部是中文");
} else {
print("该字符串不全部是中文");
}

?>

$action?=?trim($_get['action']);

if($action?==?"sub")

{

$str?=?$_post['dir'];?

//if(!preg_match("/^[".chr(0xa1)."-".chr(0xff)."a-za-z0-9_]+$/",$str))?//gb2312汉字字母数字下划线正则表达式

if(!preg_match("/^[x{4e00}-x{9fa5}a-za-z0-9_]+$/u",$str))?//utf-8汉字字母数字下划线正则表达式

{?

echo?"您输入的[".$str."]含有违法字符";?

}

else?

{

echo?"您输入的[".$str."]完全合法,通过!";?

}

}

?>

输入字符(数字,字母,汉字,下划线):

Related labels:
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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template