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

PHP Chinese and English regular expressions_PHP tutorial

WBOY
Release: 2016-07-20 11:07:16
Original
1017 people have browsed it

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...
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