php tutorial match the regular expression of Chinese characters
Regular expression matching Chinese characters: [u4e00-u9fa5] Commentary: Matching Chinese is really a headache, with this expression is easy to match the double-byte characters (including Chinese characters included): [^ x00-xff] Commentary: Can be used to calculate the length of a string (a double-byte character length meter 2, ascii character meter 1) * /
$ str = "singlepoint single point log"; if (preg_match ("/ ^ [x {4e00} -x {9fa5}] + $ / u", $ str)) { print ("This string is all Chinese"); } else { print ("This string is not all 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] = '';
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.