<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <title>42度空间-从0到1分步实现一个出生日期的校验函数-组合测试</title>
</head>
<body>
<div id="main"></div>
<script>
    console.log = function(val) {
        document.getElementById("main").innerHTML += val +"<br />";
    }
    var pattern = /^((19[2-9]\d{1})|(20[01][0-8]))\-((?:0?[1-9])|(?:1[0-2]))\-((?:0?[1-9])|(?:[1-2][0-9])|30|31)$/;
    console.log(pattern.test("1923-3-18"));
    console.log(pattern.test("1923-4-31"));
    console.log(pattern.test("1923-2-29"));
    console.log(pattern.test("2016-2-29"));
</script>
</body>
</html>