您的位置:首页 > 其它

Regular Expression -Date:MM/dd/yyyy,M/dd/yyyy

2007-09-19 08:04 351 查看

Regular Expression Details

[Find]
[Test]

TitlePattern Title
Pattern^(((((0[13578])|([13578])|(1[02]))[\-\/\s]?((0[1-9])|([1-9])|([1-2][0-9])|(3[01])))|((([469])|(11))[\-\/\s]?((0[1-9])|([1-9])|([1-2][0-9])|(30)))|((02|2)[\-\/\s]?((0[1-9])|([1-9])|([1-2][0-9]))))[\-\/\s]?\d{4})(\s(((0[1-9])|([1-9])|(1[0-2]))\:([0-5][0-9])((\s)|(\:([0-5][0-9])\s))([AM|PM|am|pm]{2,2})))?$
AuthorDavid Darling
Matching Text11/30/2003 10:12:24 am|||2/29/2003 08:14:56 pm|||5/22/2003
Non-Matching Text11/31/2003 10:12:24 am|||2/30/2003 08:14:56 pm|||5/22/2003 14:15
DescriptionFollowing
expression can be used to validate a datetime column from SQL Server.
This expression is an enhanced version of Scott Watermasysk's date/time
submission. It now accepts leading zeros in months, days, and hours. In
addition, this expression properly handles the 11th hour. Watermasysk's
would take the 10th and 12th hour but not the 11th. This regex has been
tweaked to do so. Does not handle the February 29th problem on non-leap
years yet. Will learn a little more about RegEx and do so in later
submission.
Source
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: