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