Home  >  Article  >  Backend Development  >  PHP Chinese and English regular expressions_PHP tutorial

PHP Chinese and English regular expressions_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:07:16990browse

php tutorial Chinese and English regular expressions

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



php Chinese and English regular expressions
< ;/head>






function funcChinese($str,$num1='',$num2='')//Judge Chinese regularity
{
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 'is Chinese';
}
else
{
exit('is not a valid Chinese');
}
}
//This can only be judged character by character. You can use foreach to process it
?>


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/444972.htmlTechArticlephp tutorial Chinese and English regular expressions! 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...
Statement:
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