The most complete regular check of Chinese characters: only Chinese characters are allowed, dots are allowed, extended Chinese characters are allowed, rare characters, such as Chinese characters like 䶮

Here we only talk about regular verification of Chinese names. If you need more comprehensive verification, please see another blog:

The most complete js front-end and back-end common verification method for Chinese names (with dots) in the whole network

Still the same style, always direct, no nonsense, start:

1: Verify pure Chinese characters (length is 2-6 digits):

/^([\u4e00-\u9fa5]{2,6})$/gi.test('要校验的汉字')

2: Verify Chinese characters with dots (you need to deal with various dots, please see the blog at the beginning of the article)

Allow 2-5 Chinese characters before and after the point

/^[\u4E00-\u9FA5]{2,5}([\u25CF\u00B7][\u4E00-\u9FA5]{2,5})*$/gi.test('待校验汉字')

 

 3: With rare characters, such as: 䶮 (Unicode code: 4DAE)

/^[\u9FA6-\u9FCB\u3400-\u4DB5\u4E00-\u9FA5]{2,5}([\u25CF\u00B7][\u9FA6-\u9FCB\u3400-\u4DB5\u4E00-\u9FA5]{2,5})*$/gi.test('待校验汉字');

Before and after adding Unicode codes of rare characters:

 

For the range of unicode Chinese character codes, the basic Chinese characters are generally enough, and the extension A can be brought at most, and the latter will not appear in the usual and personal names, because the system of the Civil Affairs Bureau may not be able to type it out.

character set word count Unicode encoding
Basic Chinese characters 20902 words 4E00-9FA5
basic kanji supplement 38 words 9FA6-9FCB
Extension A 6582 words 3400-4DB5
extension B 42711 words 20000-2A6D6
extension C 4149 words 2A700-2B734
extension D 222 words 2B740-2B81D
Kangxi Radicals 214 words 2F00-2FD5
radical expansion 115 words 2E80-2EF3
Compatible with Chinese characters 477 words F900-FAD9
compatible extension 542 words 2F800-2FA1D
PUA (GBK) parts 81 characters E815-E86F
Part extension 452 words E400-E5E8
PUA Supplement 207 words E600-E6CF
Chinese character strokes 36 characters 31C0-31E3
Chinese character structure 12 characters 2FF0-2FFB
Chinese phonetic notation 22 characters 3105-3120
Zhuyin extension 22 characters 31A0-31BA
1 word 3007

The above three requirements can already meet almost all scenarios. You can adjust the above rules according to your own needs, increase the range of Chinese characters, or modify the allowed number.

that's all.

Guess you like

Origin blog.csdn.net/u013282737/article/details/120512721