Ec (2); php tutorial match Chinese Character regular expression match Chinese Character Regular Expression: [u4e00-u9fa5] Comment: Match Chinese character is really a headache, with this expression, it is easy to match double byte characters (including Chinese characters): [^ x00-xff] Comment: can be used to calculate the length of a string (a double byte length 2, ascii characters 1) * & nbsp; $ str & quot; singlepoint Single Point log & quot; script ec (2); script
Regular Expression matching Chinese characters in the php tutorial
Regular Expression matching Chinese characters: [u4e00-u9fa5]
Note: matching Chinese characters is really a headache. It is easy to use this expression.
Match double byte characters (including Chinese characters): [^ x00-xff]
Comment: it can be used to calculate the length of a string (a dual-byte length Meter 2, ascii character meter 1)
*/
$ Str = "singlepoint Single Point log ";
If (preg_match ("/^ [x {4e00}-x {9fa5}] + $/u", $ str )){
Print ("all strings are Chinese ");
} Else {
Print ("Not all strings are Chinese ");
}
$ Alias_len = mb_strlen ($ value ['Alias'], "UTF-8 ");
$ Temp_array = array ();
For ($ I = 0; $ I <$ alias_len; $ I ++)
{
$ Temp_array [$ I] = mb_substr ($ value ['Alias'], $ I, 1, "UTF-8 ");
If (ord (substr ($ temp_array [$ I], 0, 1)> '0xe0' & strlen ($ temp_array [$ I]) <3)
$ Temp_array [$ I] = '';
}
$ Value ['Alias'] = implode ('', $ temp_array );