Chinese verification function (phpjavascript ). The Chinese character is determined by String Encoding. ^ [chr (0xa1)-chr (0xff)] + $ this is the regular expression for php verification to determine whether it is a Chinese character. Next, let's look at the regular expression for verifying the Chinese character. the Chinese character determination is based on string encoding./^ [chr (0xa1) -chr (0xff)] + $ this is the regular expression for php verification to determine whether it is a Chinese character. let's look at an example of Chinese verification.
The determination of Chinese characters is based on string encoding,/^ [chr (0xa1)-chr (0xff)] + $ this is the php Tutorial to verify whether the regular expression is Chinese
The following is an example of verifying Chinese characters.
$ Str = "yijucheng ";
If (preg_match ("/^ [". chr (0xa1). "-". chr (0xff). "] + $/", $ str )){
Echo "this is a pure Chinese string ";
} Else {
Echo "this is not a pure Chinese string ";
}
Js
Var str = "php programming ";
If (/^ [u4e00-u9fa5] + $/. test (str )){
Alert ("all strings are Chinese ");
} Else {
Alert ("Not all strings are Chinese ");
}
Php
If ($ en_utf8)
{$ Joid = preg_replace ("[^ 0-9a-za-z _-| x4e00-x9fa5 |: |/| # |.]", "", $ joid);} // UTF-8 Chinese match
Else
{$ Joid = preg_replace ("[^ 0-9a-za-z _-| ". chr (0xa1 ). "-". chr (0xff ). "|: |/| # |.] "," ", $ joid);} // gb2312 Chinese match
To determine whether a string is Chinese in php, we will follow this idea:
$ Str = "php programming ";
If (preg_match ("/^ [u4e00-u9fa5] + $/", $ str )){
Print ("all strings are Chinese ");
} Else {
Print ("Not all strings are Chinese ");
}
?>
Explain (0xa1)-chr (0xff)] + $ this is the php validation regular expression that determines whether it is Chinese. Next let's look at a validation Chinese instance Chinese character sentence...