let re =/^(\d{4})-(\d{2})-(\d{2})$/; let str = "2022-06-22"; if (re.test(str) { console.log("验证成功!") }