Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

use regular expression to check date format in javascript

 
kay lin
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi:
i have some code that uses regular expression to check a Date's format in javascript. The format i want is
yyyy-MM-dd HH:mm

so, the regular expression I used in my javascript is
[code]
/^(\d{2}|\d{4})(\/|-|\.)(\d{1,2})\2(\d{2}|\d{4})\s\d{2}\W\d(2)/
[code]

I am not very familar with regular expression. So If i want force the ":" to follow the 2 digits representing HH, what syntax should i use?
\D( or \W(? please let me know.

thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic