求正则判断0到20之间的整数,包括20,不包括0
1 回答

慕盖茨4494581
TA贡献1850条经验 获得超11个赞
is1to20 = str => /^(?:[1-9]|1[0-9]|20)$/.test(str);
// 测试:
new Array(20)
.join(' ')
.split(' ')
.map((_,i)=>i+1)
.forEach(_=>console.log(_, is1to20(_.toString())))
添加回答
举报
0/150
提交
取消