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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
^(?:(?:(?:0?[1-9]|1\d|2[0-8])\/(?:0?[1-9]|1[0-2]))\/(?:(?:1[6-9]|[2-9]\d)\d{2}))$|^(?:(?:(?:31\/0?[13578]|1[02])|(?:(?:29|30)\/(?:0?[1,3-9]|1[0-2])))\/(?:(?:1[6-9]|[2-9]\d)\d{2}))$|^(?:29\/0?2\/(?:(?:(?:1[6-9]|[2-9]\d)(?:0[48]|[2468][048]|[13579][26]))))$
Description
This expression validates dates in the Brazilian d/m/y format from 1/1/1600 - 12/31/9999. The days are validated for the given month and year. Leap years are validated for all 4 digits years from 1600-9999. Days and months must be 1 or 2 digits and may have leading zeros. Years must be 4 digit years, between 1600 and 9999. Date separator must be a slash (/)
Matches
29/02/2004 | 15/3/1824 | 31/01/2001
Non-Matches
29/02/2000 | 21/10/92 | 31/02/2001
Author Rating: Not yet rated. Felipe Braga
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: Correction by Mario introduces bug + 29/02
Name: Mauro Sans
Date: 8/1/2007 11:14:01 AM
Comment:
When you replaced 0?[13578]|1[02] with (0?[13578]|1?[02]), you introduced the possibility to enter 31/0/xxxx After the "1" you shouldn't insert a ?. And, the rules say that 29/02/1600, 2000, 2400, etc. should work. So I fixed it: ^(?:(?:(?:0?[1-9]|1\d|2[0-8])\/(?:0?[1-9]|1[0-2]))\/(?:(?:1[6-9]|[2-9]\d)\d{2}))$|^(?:(?:(?:31\/(?:0?[13578]|1[02]))|(?:(?:29|30)\/(?:0?[1,3-9]|1[0-2])))\/(?:(?:1[6-9]|[2-9]\d)\d{2}))$|^(?:29\/0?2\/(?:(?:(?:1[6-9]|[2-9]\d)(?:0[48]|[2468][048]|[13579][26]))|1600|2000|2400|2800))$


Title: problems with 31/10/yyyy and 31/12/yyyy
Name: Mario Dias
Date: 10/26/2006 4:34:47 PM
Comment:
I replaced 0?[13578]|1[02] with (0?[13578]|1?[02]). It seems to work. The complete expression should be : ^(?:(?:(?:0?[1-9]|1\d|2[0-8])\/(?:0?[1-9]|1[0-2]))\/(?:(?:1[6-9]|[2-9]\d)\d{2}))$|^(?:(?:(?:31\/(0?[13578]|1?[02]))|(?:(?:29|30)\/(?:0?[1,3-9]|1[0-2])))\/(?:(?:1[6-9]|[2-9]\d)\d{2}))$|^(?:29\/0?2\/(?:(?:(?:1[6-9]|[2-9]\d)(?:0[48]|[2468][048]|[13579][26]))))$


Title: Problem with 31/12
Name: Pathik Thaker
Date: 9/27/2006 3:21:11 AM
Comment:
It is not allowing 31st Dec with any year. Please check it.


Title: problem with 31/12/1999
Name: O. Crhonek
Date: 3/12/2004 9:56:56 AM
Comment:
does not match for correct date 31/12/1999


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