Regular matching Chinese problem

condition: match Chinese and English with an underscore of 5-15 digits
var pattern = / ^ [u4E00-u9FA5A-Za-z0-9] {5jue 15} $/; do you think there is a problem with this regularity? The problem is that individual Chinese characters cannot match
var str = "local aa123_";
pattern.test (str); / / returns false

Mar.01,2021

there are two problems:

  1. you forgot to add the backslash (or markdown lost it for you). It should be like this
var pattern = /^[\u4E00-\u9FA5A-Za-z0-9_]{5,15}$/;
The word
  1. "u9FA5A" (\ u3DE3 ) is not in the range of \ u4E00 -\ u9FA5A .

the correct way to write it should be

/^[A-Za-z0-9_\u4E00-\u9FA5]{5,15}$/

that 'encoding' doesn't match because its unicode code is \ u3de3

question:
Unicode Chinese character coding range u4E00-u9FA5
Unicode Chinese character coding Table
query the coding table and find that the (xing) character is not in the Unicode coding range, so it will return false
unicode to Chinese, and Chinese to unicode, refer to @ zifengb
modified regular expression

.
var pattern = /^[\u4e00-\u9fa5\u3de3_a-zA-Z0-9]{5,15}$/; 
var str = "aa123_"; 
str.match(pattern);
Menu