<!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 = /^((0?[1-9])|([1-2][0-9])|30|31)$/;
    console.log(pattern.test("32"));
    console.log(pattern.test("02"));
    console.log(pattern.test("2"));
    console.log(pattern.test("19"));
    console.log(pattern.test("28"));
</script>
</body>
</html>