显然考察的是正则表达式,没用正则表达式的方式一定很蠢吧
function matchesPattern(str) {
for (let i = 0; i < str.length; i++) {
if (i == 3 || i == 7) {
// console.log(i);
continue;
} else if ((str[i] >= '0') && (str[i] <= '9')) {
continue;
} else {
return false;
}
}
let tem = str.split('-');
// console.log(tem);
if (tem.length == 3) {
if (tem[0].length == 3 && tem[1].length == 3 && tem[2].length == 4) {
// console.log(tem[0]);
// console.log(tem[1]);
// console.log(tem[2]);
return true;
}
} else {
return false;
}
return false;
} 


京公网安备 11010502036488号