判断字符串是否含有中文字符:
var pattern = /.*[\u4e00-\u9fa5]+.*$/; var str = "asd按时"; console.log(pattern.test(str));
判断字符串是否全为英文:
var pattern = new RegExp("^[a-zA-Z]+$"); var str = "asd按时"; console.log(pattern.test(str));
判断字符串中是否含有+、-、*、/运算符:
var pattern = /[+*/-]/; var str = "asd按时"; console.log(pattern.test(str));
正则表达式在线生成工具:http://tools.jb51.net/regex/create_reg