How to solve a regular expression

Source: Internet
Author: User
You can find a regular expression that matches all the visible characters on the keyboard, including @ # $ ...... & Amp; & #215; () and so on. all the information displayed on the keyboard matches, but does not include Chinese, Russian, and so on., PHPcode $ str = '~! @ # $ % ^ & Amp; * () _ + 0124JHB & quot; Hello ghjk '; preg_match_all ('/[[: punct:] \ w find a regular expression
It can match all visible characters on the keyboard, including @ # $ ...... & × () And so on. everything on the keyboard matches, but not Chinese or Russian ..

------ Solution --------------------
PHP code
$ Str = '~! @ # $ % ^ & * () _ + 0124JHB "Hello ghjk '; preg_match_all ('/[[: punct:] \ w]/I ', $ str, $ m); print_r ($ m );
------ Solution --------------------
\ W is an underscore (_)
------ Solution --------------------
Your environment is a bit abnormal, which may be caused by version and encoding problems.
Under normal circumstances, \ w cannot match Chinese.
I can't use [[: punct:] a-z0-9 _]/I
------ Solution --------------------
Indeed, you are not a unicode file.

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.