PHP Validation Chinese Express!!!!!!!

Source: Internet
Author: User
Tags ereg posix preg
PHP U9

How to use PHP to verify Chinese letters and numbers,

[\U4E00-\U9FA5] This can be verified in Chinese????? Tokyu


Reply to discussion (solution)

[\x4e00-\x9fa5]

It should be [\X4E00-\X9FCF]
Now the software basically supports the Unicode 6.1 version, can not use the old three

No, [\u4e00-\u9fa5] is the JS regular use

Now that you think of it, you're using a utf-8 code.
PHP regular writing [\x{4e00}-\x{9fa5}] plus u modifier
But now that you have the U modifier, \w already contains Chinese.

It should be [\X4E00-\X9FCF]
Now the software basically supports the Unicode 6.1 version, can not use the old three

if (Ereg (' ^[\x4e00-\x9fcf]{1,100}$ ', ' haha haha only ')) {
echo "Pass";
}else{
echo "Error";
}
?>
Or is it wrong?

No, [\u4e00-\u9fa5] is the JS regular use

Now that you think of it, you're using a utf-8 code.
PHP regular writing [\x{4e00}-\x{9fa5}] plus u modifier
But now that you have the U modifier, \w already contains Chinese.

gb2312 not understand JS also use is gb2312

The browser unifies all incoming data into Unicode encoding, which is ucs-2 for the Simplified Chinese environment.
And \u4e00-\u9fa5 is the Ucs-2 encoding range of Chinese characters.

The browser unifies all incoming data into Unicode encoding, which is ucs-2 for the Simplified Chinese environment.
And \u4e00-\u9fa5 is the Ucs-2 encoding range of Chinese characters.

Yes, I understand.

But you said I couldn't use it in Eregi.

if (eregi ()) {
Ecjp ' right ';
}

Thank you!!!

Echo ' right ';

Is Ereg supported????

The Ereg series uses the POSIX regular
The Preg series uses the PCRE regular
They are not compatible!

and the Ereg function group will be abolished in the near future, it is recommended not to use

The Ereg series uses the POSIX regular
The Preg series uses the PCRE regular
They are not compatible!

and the Ereg function group will be abolished in the near future, it is recommended not to use


Thank you very much!!!

  • Contact Us

    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.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.