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.
我正在使用这个表达式^(([0-9])|([0-1][0-9])|([2][0-3])):(([0-9])|([0-5][0-9]))$,它非常适合用冒号验证军事时间......我如何修改它以使其在 10 次以下时需要前导零?
^(([0-9])|([0-1][0-9])|([2][0-3])):(([0-9])|([0-5][0-9]))$
Git 摆脱了([0-9])|朝开始的表达式。那只允许一位数字。之后的东西| 需要两位数。
([0-9])|
只需删除第一个交替:
^(([0-1][0-9])|([2][0-3])):(([0-9])|([0-5][0-9]))$
它是一个允许个位数小时数的。
^(([0-1][0-9])|([2][0-3])):(([0-5][0-9]))$
此版本要求小时和分钟均为 2 位数字。