3

what is the regular expression for HH:MM:SS

HH is hours , but not limited for day or clock it just can be any number from 0 to any integer

MM is minutes maximum is 59 and begin from 00

SS is Seconds maximum is 59 and begin from 00

4

1 回答 1

7
([0-9]+):([0-5][0-9]):([0-5][0-9])

if the maximum is 59 (sensible). If you want 60 to also be possible,

([0-9]+):([0-5][0-9]|60):([0-5][0-9]|60)

EDIT: If you want the leading zero to be optional, the one in the comment works. This one is better tho:

([0-9]+):([0-5]?[0-9]):([0-5]?[0-9])
于 2013-10-31T00:52:10.367 回答