【发布时间】:2014-05-31 12:10:04
【问题描述】:
我愿意接受以下格式:
"23:59", "2:3:04", "02:00:09", "23:07:00"
使用这个正则表达式模式:
return Regex.IsMatch(timeIn, @"^([0-2]?[0-9]:[0-5]?[0-9])|([0-2]?[0-9]:[0-5]?[0-9]:[0-5]?[0-9])$") ? true : false;
不幸的是,它也接受其他格式,例如:00:00:99
我做错了什么?谢谢。
【问题讨论】:
-
写一个更好的标题..meta.stackexchange.com/questions/10647/…
-
"((?:(?:[0-1][0-9])|(?:[2][0-3])|(?:[0-9]) ):(?:[0-5][0-9])(?::[0-5][0-9])?(?:\\s?(?:am|AM|pm|PM) )?)"
标签: c# regex time-format