检测八位数字是否为有效日期的正则
时间:2020-07-25 17:13 来源/作者:正则之家
-
<html>
-
<head>
-
<title>测试八位数字是否为有效日期</title>
-
</head>
-
<script language="javascript"><!-- function fun1() { var str1=document.getElementById("str1").value; var str2=document.getElementById("str2").value; var regex1 = new RegExp(str2,'g'); return regex1.test(str1); } function fun2(){alert(fun1());} // --></script>
-
<body>
-
<div>
-
<span>String : </span><input id="str1" type="text" value="19990228" size="100"/><span>Regex : </span><input id="str2" type="text" value='^(?:(?:(?:(?=\d{2}(?:(?:[02468][048])|(?:[13579][26])))\d{4}02(?!00)[0-2]\d))|(?:\d{4}(?:(?:(?:(?:0[469])|(?:11))(?!00)(?:(?:[0-2]\d)|(?:30)))|(?:(?:(?:0[13578])|(?:1[02]))(?!00)(?:(?:[0-2]\d)|(?:3[01])))|(?:02(?!(?:00)|(?:29))[0-2]\d))))$' size="100"/><input type="button" value="OK" onclick="javascript:fun2();"/>
-
</div>
-
</body>
-
</html>
相关文章
热门资讯