JS高级---识别正则表达式是否匹配
识别正则表达式是否匹配
console.log(/[a-zA-Z]+/.test("hello")); console.log(/./.test("除了回车换行以为的任意字符"));//true console.log(/.*/.test("0个到多个"));//true console.log(/.+/.test("1个到多个"));//true console.log(/.?/.test("哈哈"));//true console.log(/[0-9]/.test("9527"));//true console.log(/[a-z]/.test("what"));//true console.log(/[A-Z]/.test("Are"));//true console.log(/[a-zA-Z]/.test("干啥子"));//false console.log(/[0-9a-zA-Z]/.test("9ebg"));//true console.log(/b|(ara)/.test("abra"));//true console.log(/[a-z]{2,3}/.test("arfsf"));//true
console.log(/\d/.test("998")); //true console.log(/\d*/.test("998")); console.log(/\d+/.test("998")); console.log(/\d{0,}/.test("998")); console.log(/\d{2,3}/.test("998")); console.log(/\D/.test("eat")); console.log(/\s/.test(" ")); console.log(/\S/.test("嘎嘎 ")); console.log(/\w/.test("_")); console.log(/\W/.test("_"));
相关推荐
wangzhaotongalex 2020-10-20
wyq 2020-11-11
TLROJE 2020-10-26
风雨断肠人 2020-10-13
duanqingfeng 2020-09-29
rechanel 2020-11-16
cshanzhizi 2020-10-16
luofuIT成长记录 2020-09-22
phphub 2020-09-10
taomengxing 2020-09-07
MaggieRose 2020-08-19
flyingssky 2020-08-18
山水沐光 2020-08-18
jyj00 2020-08-15
AHuqihua 2020-08-09
山水沐光 2020-08-03