当前位置:Gxlcms > PHP教程 > php中文与英语正则表达式_PHP教程

php中文与英语正则表达式_PHP教程

时间:2021-07-01 10:21:17 帮助过:2人阅读

php教程 中文与英语正则表达式

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



php 中文与英语正则表达式




function funcChinese($str,$num1='',$num2='')//判断中文正则
{
if($num1!='' and $num2!=''){
return (preg_match("/^([x81-xfe][x40-xfe])

{".$num1.",".$num2."}$/",$str))?true:false;
}else{
return (!eregi("[^x80-xff]","$str"))?

true:false;
}
}

if( $_POST)
{
if( funcChinese( $_POST['url'] ) )
{
echo '是中文';
}
else
{
exit('不是有效中文');
}
}
//这个只能一个个字符判断哦,你可以用foreach来处理
?>


www.bkjia.comtruehttp://www.bkjia.com/PHPjc/444972.htmlTechArticlephp教程 中文与英语正则表达式 !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd html xmlns=http://www.w...

人气教程排行