您的位置:首页 > 其它

日期正则表达式

2006-10-08 15:46 155 查看
^(?=/d)(?:(?!(?:1582(?:/.|-|//)10(?:/.|-|//)(?:0?[5-9]|1[0-4]))|(?:1752(?:/.|-|//)0?9(?:/.|-|//)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:/d/d)(?:[02468][048]|[13579][26]))/D0?2/D29)|(?:/d{4}/D(?!(?:0?[2469]|11)/D31)(?!0?2(?:/.|-|//)(?:29|30))))(/d{4})([-//.])(0?/d|1[012])/2((?!00)[012]?/d|3[01])(?:$|(?=/x20/d)/x20))?((?:(?:0?[1-9]|1[012])(?::[0-5]/d){0,2}(?:/x20[aApP][mM]))|(?:[01]/d|2[0-3])(?::[0-5]/d){1,2})?$

Description: yyyy/mm/dd hh:MM:ss Datetime for all AD years, including leap years. Javascript safe version of http://regexlib.com/REDetails.aspx?regexp_id=760. Please see that regex for details of what is being checked
Matches: [0008-02-29], [2:34:59 PM], [9999/12/31 11:59 PM]
Non-Matches: [04/04/04], [1:00], [1999/1/32]
转自:http://blog.csdn.net/lonz/archive/2005/03/22/326751.aspx
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: