题解 | #判断是否符合指定格式 - 不适用正则[zhl]#
判断是否符合指定格式
https://www.nowcoder.com/practice/eb86f08c478749868a01861f5ddad28b
function matchesPattern(str) { const splitArr = str.split('-') return splitArr.every((item, idx) => { return !isNaN(Number(item)) && (idx == 2 ? item.length==4 : item.length==3) }) }