This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes use regular expression to check date format in javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "use regular expression to check date format in javascript" Watch "use regular expression to check date format in javascript" New topic
Author

use regular expression to check date format in javascript

kay lin
Ranch Hand

Joined: May 20, 2004
Posts: 132
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
 
Consider Paul's rocket mass heater.
 
subject: use regular expression to check date format in javascript
 
Similar Threads
Problem with a regex
A query about Patten in Java Regular Expression
using regular expression Problem
question : retailer code must contain only 2 alphabets and 3 numbers i.e AB123
Using Patterns for Date String