Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 520
  • Last Modified:

REGEX for mm/dd/yyyy

Hi,
Does anyone have a simple regex to just verify "mm/dd/yyyy" where the "m", "d" and "y" are numeric.  I have a server side test for a valid date (in Coldfusion) but it accepts any valid date format.  I'd like to force the input to be mm/dd/yyyy and edit it on the server.

Thanks in advance,
hefterr
0
hefterr
Asked:
hefterr
  • 2
  • 2
1 Solution
 
Patrick MatthewsCommented:
This does not test for a proper month-end date (e.g., it will accept 02/31/2010):

^[01][1-9]/[0-3]\d/\d{4}$
0
 
hefterrAuthor Commented:
Hey matthewspatrick,
Thanks much!  Works great!  
0
 
ozoCommented:
but it doesn't accept 10/10/2010
0
 
hefterrAuthor Commented:
Hi ozo and matthewspatrick,
hmmmmm, so should it just be : ^[01][0-9]/[0-3]\d/\d{4}$        ??

hefterr
0
 
ozoCommented:
I think that would be better
[0-9] can also be written \d
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now