Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试验证军事时代。我想接受像 19:25 这样的时间,但不是 1925。我当前的表达式不接受:. 我在这里想念什么?
:
([01][0-9])|(2[0-3])[0-5][0-9]
接受不带冒号的时间(([01][0-9])|(2[0-3]))[0-5][0-9]:(您缺少一组括号。)
(([01][0-9])|(2[0-3]))[0-5][0-9]
如果您想接受带冒号的时间:(([01][0-9])|(2[0-3])):[0-5][0-9]
(([01][0-9])|(2[0-3])):[0-5][0-9]
如果您希望冒号是可选的:(([01][0-9])|(2[0-3])):?[0-5][0-9]
(([01][0-9])|(2[0-3])):?[0-5][0-9]