Here is an expression
const reg = new RegExp(`^([\\u4e00-\\u9fa5a-zA-Z0-9_-]){1,${num}}$`)
Which design to detect a wold\'s length less than