Ec (2); php tutorial regular Chinese expression $ str & quot; abc One Two Three cde & quot; echopreg_replace ([^ x4e00-x9fa5] I, & quot ;, $ str); $ str & quot; php programming & quot; if (preg_match (& quot; ^ [x4e00-x9fa5] + $ u & quot;, $ str )) {pri script ec (2); script
Php tutorial Regular Expression
$ Str = "abc One, Two, Three cde ";
Echo preg_replace ('/[^ x4e00-x9fa5]/I', "", $ str );
$ Str = "php programming ";
If (preg_match ("/^ [x4e00-x9fa5] + $/u", $ str )){
Print ("all strings are Chinese ");
} Else {
Print ("Not all strings are Chinese ");
}
?>
$ Action? =? Trim ($ _ get ['action']);
If ($ action? ==? "Sub ")
{
$ Str? =? $ _ Post ['dir'];?
// If (! Preg_match ("/^ [". chr (0xa1). "-". chr (0xff). "a-za-z0-9 _] + $/", $ str ))? // Gb2312 Regular Expression of Chinese characters, letters, numbers, underscores (_)
If (! Preg_match ("/^ [x {4e00}-x {9fa5} a-za-z0-9 _] + $/u", $ str ))? // UTF-8 Regular Expression for Chinese characters, letters, numbers, underscores (_)
{?
Echo? "The [". $ str. "] You entered contains illegal characters ";?
}
Else?
{
Echo? "The [". $ str. "] You entered is completely legal. Pass! ";?
}
}
?>