题解 | #密码验证合格程序#正则就好了
密码验证合格程序
http://www.nowcoder.com/practice/184edec193864f0985ad2684fbc86841
const list = []
let itm;
while(itm=readline()){
list.push(itm)
}
for(let itm of list){
if(!(/.{9,}/.test(itm))){
console.log('NG');
continue;
}
let sum = 0;
if(/[a-z]/.test(itm))sum++
if(/[A-Z]/.test(itm))sum++
if(/[\d]/.test(itm))sum++
if(/[^\da-zA-Z]/.test(itm))sum++
if(sum<3){
console.log('NG');
continue;
}
if(/(.{3,}).*\1/g.test(itm)){
console.log('NG');
}else {
console.log('OK');
}
}