User name, you can enter the Chinese language can also be entered in English,
How do I write the regular to judge it.
You can't lose in China and England.
Chinese 10 characters or less. English is available within 30 letters.
Let's talk about how to use the regular to deal with such problems.
Reply to discussion (solution)
Chinese = = = "\x{4e00}-\x{9fa5}
English A-Z
So you can:
/^ ([\x{4e00}-\x{9fa5}]{1,10}| [A-z] {1,30}) $/iu
Don't know if you allow spaces
$pattern = "/^ ([\x{4e00}-\x{9fa5}]{1,10}|[ 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 "
"; }
Chinese = = = "\x{4e00}-\x{9fa5}
English A-Z
So you can:
/^ ([\x{4e00}-\x{9fa5}]{1,10}| [A-z] {1,30}) $/iu
Don't know if you allow spaces
PHP Code?123456789$pattern = "/^ ([\x{4e00}-\x{9fa5}]{1,10}|[ a-z]{1,30}) $/iu "; $test ...
I'll try, look at the effect, THANKS,
Chinese = = = "\x{4e00}-\x{9fa5}
English A-Z
So you can:
/^ ([\x{4e00}-\x{9fa5}]{1,10}| [A-z] {1,30}) $/iu
Don't know if you allow spaces
PHP Code?123456789$pattern = "/^ ([\x{4e00}-\x{9fa5}]{1,10}|[ a-z]{1,30}) $/iu "; $test ...
Ok. You are right to learn from you. Checkout ~ ~ ~