Solved

REGEX for mm/dd/yyyy

Posted on 2010-09-11
5
486 Views
Last Modified: 2013-12-24
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
Comment
Question by:hefterr
  • 2
  • 2
5 Comments
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 500 total points
ID: 33653727
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
 
LVL 1

Author Comment

by:hefterr
ID: 33653800
Hey matthewspatrick,
Thanks much!  Works great!  
0
 
LVL 84

Expert Comment

by:ozo
ID: 33655362
but it doesn't accept 10/10/2010
0
 
LVL 1

Author Comment

by:hefterr
ID: 33656505
Hi ozo and matthewspatrick,
hmmmmm, so should it just be : ^[01][0-9]/[0-3]\d/\d{4}$        ??

hefterr
0
 
LVL 84

Expert Comment

by:ozo
ID: 33657414
I think that would be better
[0-9] can also be written \d
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Parse CSS value with RegEx 2 78
change time in cron 4 87
Public IP Address Amazon Servers 2 57
Ubuntu Apache Webserver - File Permissions 5 59
A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question