在ASP.NET MVC中正常表达时间08:00 - 21:00?

时间:2016-05-03 10:50:57

标签: asp.net regex asp.net-mvc

我需要一个输入字段的正则表达式,它匹配08:00到21:00之间的任何小时,包括。这意味着像08:00,12:47,16:19和21:00这样的时间是正确的。 07:59,21:01,22:00等不正确。

我提出了这个注册前[ { "name": "ABC", "date": 1459461600000, "attr001": "SIGN1", "val001": "7", "attr002": "SIGN2", "val002": "7", "attr003": "SIGN3", "val003": "100.00", "attr004": "SIGN4", "val004": "0" }, { "name": "ABC", "date": 1459461600000, "attr001": "SIGN1", "val001": "20", "attr002": "SIGN2", "val002": "70", "attr003": "SIGN3", "val003": "100.00", "attr004": "SIGN4", "val004": "50" }, { "name": "XYZ", "date": 1459125900000, "attr001": "VISSE1", "val001": "100", "attr002": "VISSE2", "val002": "7", "attr003": "VISSE3", "val003": "300.00", "attr004": "VISSE4", "val004": "0" }, { "name": "XYZ", "date": 1459461600000, "attr001": "VISSE1", "val001": "50", "attr002": "VISSE2", "val002": "70", "attr003": "VISSE3", "val003": "300.00", "attr004": "VISSE4", "val004": "0" }, { "name": "XYZ", "date": 1459461900000, "attr001": "VISSE1", "val001": "300", "attr002": "VISSE2", "val002": "10", "attr003": "VISSE3", "val003": "500.00", "attr004": "VISSE4", "val004": "0" } ] ,我认为它有效,但后来我发现事实并非如此。 10:00到19:59之间的所有时间都不正确。我该如何解决?

1 个答案:

答案 0 :(得分:2)

这个怎么样?

(0[8-9]:[0-5][0-9]|1[0-9]:[0-5][0-9]|20:[0-5][0-9]|21:00)

此示例here中显示的是按照您的意愿工作。