且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

用于日期时间格式的正则表达式

更新时间:2023-11-29 11:14:28

而不是重新发明***,请参阅 ^ ],它具有类似的表达式.请注意:它们很复杂,因此,如果它们不能完全满足您的需求,那么您的工作将会很漫长.获取 Expresso [ ^ ]它是免费的,可以真正帮助调试正则表达式!

我不知道您要达到什么目的,但是使用 DateTime.ParseExact [ ^ ]代替...
Rather than re-invent the wheel, see http://regexlib.com/DisplayPatterns.aspx?cattabindex=4&categoryId=5[^] which has similar expressions. Be warned though: they are complex, so if they don;t fit your need exactly, then you have a long job ahead. Get a copy of Expresso[^] it''s free and can really help debug a regex!

I don''t know what you are trying to achieve, but you may be better off using DateTime.ParseExact[^] instead...


^((((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])|((16|[2468][048]|[3579][26])00))))|(0?[1-9]|1\d|2[0-8])\/((0?[1-9])|(1[0-2]))\/((1[6-9]|[2-9]\d)?\d{2})) (20|21|22|23|[0-1]?\d):[0-5]?\d:[0-5]?\d




希望对您有所帮助.



Hope this can help you.