Using regular matches in Vim Chinese

Source: Internet
Author: User

As we all know, when using JS's regular to verify Chinese, you can use:

/[\u4e00-\u9fa5]+/.test (' Chinese ')



However, when you use this regular in Vim, you will be prompted not to find a match

E384: The Beginning (end) of the file found is still missing [\u4e00-\u9fa5]+



In fact, Vim has a ' magic ' setting when searching, and when the magic is set to a different situation (the default setting is Magic), the regular expressions are written differently:

    • Magic: All characters except ' ^.*$ ' need to be inverted slash
    • nomagic: All characters except ' ^$ ' need to be inverted slash
    • Very magic: No characters are required to add backslashes
    • Very nomagic: Any font needs to be inverted slash

You can specify what kind of magic to use in regular expressions

    • \m:magic
    • \m:nomagic
    • \v:very Magic
    • \v:very nomagic

For example:

\v[\u4e00-\u9fa5]+ "Find Chinese



So the problem is clear at a glance:

[\u4e00-\u9fa5]\+  ] default to Magic, ' + ' need to add backslash



For multibyte text, VIM can also use words such as ' \u1234 ' that are less than ' 0xffffffff ' in addition to ' \u '.

Using regular matches in Vim Chinese

Related Article

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.