Ask the username for the regular expression. you can enter Chinese or English. how can I write the regular expression to judge it. It cannot be mixed between Chinese and English. it can contain less than 10 Chinese characters. You can use either of the following 30 letters. Let's talk about how to use regular expressions to deal with such problems ?, Question about regular expressions in Chinese & nbsp ;==
User name. you can enter either Chinese or English,
How can I write a regular expression to determine it.
Cannot mix Chinese and English,
Within 10 Chinese characters. You can use either of the following 30 letters.
Let's talk about how to use regular expressions to deal with such problems?
------ Solution --------------------
Chinese ===" \ x {4e00}-\ x {9fa5}
English a-z
Therefore, you can:
/^ ([\ X {4e00}-\ x {9fa5}] {1, 10}
------ Solution --------------------
[A-z] {1, 30}) $/iu
I wonder if you allow spaces
$ Pattern = "/^ ([\ x {4e00}-\ x {9fa5}] {1, 10}
------ Solution --------------------
[A-z] {1, 30}) $/iu ";
$ Test = array ("This is Chinese", "Chinese and English", "thisisenglish ");
Foreach ($ test as $ word ){
Echo $ word;
Echo ":";
Echo preg_match ($ pattern, $ word );
Echo"
";
}