当前位置:首页 > 通信资讯 > 正文

八位日期正则表达式(正则表达式匹配八位日期)

  1. <html>
  2. <head>
  3. <title>测试八位数字是否为有效日期</title>
  4. </head>
  5. <scriptlanguage="javascript"><!--/*//RegexExampleinJavaScript//RainsomeStudio//2009-07-16inShanghai//测试八位数字是否为有效日期*/functionfun1(){varstr1=document.getElementById("str1").value;varstr2=document.getElementById("str2").value;varregex1=newRegExp(str2,'g');returnregex1.test(str1);}functionfun2(){alert(fun1());}//--></script>
  6. <body>
  7. <div>
  8. <span>String:</span><inputid="str1"type="text"value="19990228"size="100"/><span>Regex:</span><inputid="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"/><inputtype="button"value="OK"onclick="javascript:fun2();"/>
  9. </div>
  10. </body>
  11. </html>
如果您对该产品感兴趣,请填写办理(客服微信:xiaoxiongyidong)

为您推荐:

发表评论

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。