RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Date dd-mm-yyyy with leap year
Expression
^(((0[1-9]|[12]\d|3[01])[\s\.\-\/](0[13578]|1[02])[\s\.\-\/]((19|[2-9]\d)\d{2}))|((0[1-9]|[12]\d|30)[\s\.\-\/](0[13456789]|1[012])[\s\.\-\/]((19|[2-9]\d)\d{2}))|((0[1-9]|1\d|2[0-8])[\s\.\-\/]02[\s\.\-\/]((19|[2-9]\d)\d{2}))|(29[\s\.\-\/]02[\s\.\-\/]((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))$
Description
Checks date in format dd-mm-yyyy. Seperation characters can be -/. and space. dd and mm HAVE to be two characters. Year has to be four characters and minimum 1900. Expression handles leap year as well
Matches
20-02-1975 | 20.02.1975 | 20/02/1975 | 20 02 1975 | 20-12/1975
Non-Matches
20-12-1899 | 29-02-2002 | 28-2-2008
Author Rating: The rating for this expression. Dennis Betten
Source
Your Rating
Bad Good

Enter New Comment

Title

Name

Comment

Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Title: Re: A few oversights
Name: Dennis Betten
Date: 1/28/2008 9:50:06 AM
Comment:
Michael, Thanx for your reply. If you feel the need to fix the holes in my expression, please feel free to do so!! I unfortunatly don't have the time right now to fix them... CU Dennis (@bharat: Hope you found help already...)


Title: how to make percentage code? plz give reply .
Name: bharat parmar ([email protected])
Date: 1/22/2008 2:23:02 AM
Comment:
i m work on php with symfony frame work i have a field named 'percentage' in which i want to enter only numberice values between 0 to 100 and also with decimal like,, e.g. 0.99, 12.56, 99.99 so, which type of regex can be used, plz reply and sorry for bad english regards, bharat parmar


Title: A few oversights
Name: Michael Ash
Date: 1/16/2008 11:23:58 AM
Comment:
First minor point except for the hyphen none of the other separators need to be escaped and with better placement neither would the hyphen. Secondly and more importantly \s does not just match a space, but all whitespaces meaning you have a lot more allowable separators than you've listed. Third as you've copied my leap year pattern verbatim leap day dates can fall below your minimum year.


Title: Nice one
Name: Pascal
Date: 1/16/2008 8:49:33 AM
Comment:
Finally a good one for the Dutch (and all other countries with dd-mm-jjjj format) Good job, thnx


Copyright © 2001-2025, RegexAdvice.com | ASP.NET Tutorials