js 正则表达式 取反

http://www.w3school.com.cn/jsref/jsref_obj_regexp.asp

 

以匹配中文为例

const test_value = '李钊鸿'

if (/[^\u4e00-\u9fa5]/.test(test_value)) {
      return console.log('请输入中文汉字')
} else {
      return console.log("合法中文汉字");
}

 

posted @ 2017-11-24 16:24  贝尔塔猫  阅读(20187)  评论(0编辑  收藏  举报