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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
^(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0?[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)0?2\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$
Description
This expression validates dates in the ITALIAN d/m/y format from 1/1/1600 - 31/12/9999. The days are validated for the given month and year. Leap years are validated for all 4 digits years from 1600-9999, and all 2 digits years except 00 since it could be any century (1900, 2000, 2100). Days and months must be 1 or 2 digits and may have leading zeros. Years must be 2 or 4 digit years. 4 digit years must be between 1600 and 9999. Date separator may be a slash (/), dash (-), or period (.) Thanks to Michael Ash for US Version
Matches
29/02/1972 | 5-9-98 | 10-11-2002
Non-Matches
29/02/2003 | 12/13/2002 | 1-1-1500
Author Rating: Not yet rated. Marco Storti
Source Marco Storti
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: mm/dd/yyyy strictly!
Name: mucluck
Date: 11/1/2018 6:33:23 PM
Comment:
^(?:(?:(?:0[13578]|1[02]))(\/|-|\.)31\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9][1-9])\d{2})$


Title: Not working with .NET 4 for ASP
Name: Zakaria
Date: 5/12/2011 5:21:14 AM
Comment:
Hi, I was trying to use this reg exp, but i can't get it working. I am using ASP.NET (Framework 4). Any date I give it shows the error message. Do u you have any idea. Cheers


Title: mm/dd/yyy ,mm-dd-yyyy and mm.dd.yyyy
Name: Sarath Pathipati
Date: 1/29/2011 8:16:19 PM
Comment:
Hi, I need regular expression which accepts date format as mm/dd/yyy ,mm-dd-yyyy and mm.dd.yyyy.The exp should validate leap year and all the date validations. Thanks, Sarath


Title: Working great
Name: Michiel
Date: 10/13/2008 6:31:06 AM
Comment:
Thank you Marco for this great regex. But what do i change to validate it between 1950 and 2002 ?


Title: great
Name: Oliver
Date: 2/12/2008 6:10:47 AM
Comment:
Thank you very much for this great regex! :-)


Title: great
Name: Oliver
Date: 2/12/2008 6:10:21 AM
Comment:
Thank you very much for this great regex! :-)


Title: ASP.NET
Name: Christopher
Date: 12/1/2006 5:27:26 AM
Comment:
@Bert: I think it might be too late but as I just saw your query I might as well respond. String s = @"\d\s\d"; the @ sign before the string ignores the escape sequences. cheers


Title: Not accepting any thing
Name: Bhaskar Reddy
Date: 9/27/2006 7:00:06 AM
Comment:
Hi, Please try with this 5-5-81,10-10-1981,like that and verify some were it is wrong regards bhaskar


Title: Re : For all those who thinks this is Great
Name: Sanjaya
Date: 11/25/2003 5:52:45 AM
Comment:
Sorry It was my Mistake ...This realy works ... Great stuff & Thank alot . Please forgive me .. :-)


Title: For all those who thinks this is Great
Name: Sanjaya
Date: 11/25/2003 5:37:33 AM
Comment:
Hey Check for these dates 12/12/2003 ,12/02/1972 etc. Can u answer .... Are they working ????


Title: Super!! Good TKY2
Name: Ferdynilli Garcé
Date: 11/14/2003 7:14:52 AM
Comment:
This really work!! ,, great stuff


Title: ASP.NET
Name: Bert
Date: 10/30/2003 5:01:15 AM
Comment:
Does anyone know how to convert the expressions so i dont get the unrecognized escape sequence error. When i copy them into a string i currently i have the error saying unrecognized escape sequence.


Title: ASDARSDFAS
Name: DASDA
Date: 10/15/2003 4:56:26 AM
Comment:
DOES NOT WORK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!111


Title: Dead Clever
Name: Tim Brown
Date: 9/22/2003 9:56:35 AM
Comment:
It even gets 29th Feb valid for leap years, but invalid for turns of century but valid for new millenium - wow - who on earth knows that stuff


Title: Thanks
Name: Pavlo
Date: 9/2/2003 7:33:12 AM
Comment:
It saved me a lot of time, thanks.


Title: At last!
Name: Anthony
Date: 9/1/2003 6:09:50 AM
Comment:
You're my hero!!! It works great! Thanks man!!!


Title: Yes it is..
Name: Henry
Date: 8/5/2003 2:32:15 AM
Comment:
it helped me alot..


Title: one of the best
Name: sam
Date: 7/15/2003 9:20:37 AM
Comment:
It's great:)


Title: Great stuff
Name: Cliff
Date: 6/27/2003 9:23:37 AM
Comment:
It's great. What do I need to change to make it strict format : dd-mm-yyyy i.e. no 2 digit years? cheers


Title: Excelent
Name: vk
Date: 5/29/2003 12:19:55 PM
Comment:
Very handy


Title: Well done
Name: wirelessjunkie
Date: 5/20/2003 10:56:23 AM
Comment:
Pretty good stuff ! This regex rules ! Thanks a lot :)


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