fork(6) download
  1. import re
  2.  
  3. timestamp_regex = r'(2[0-3]|[01][0-9]|[0-9]):([0-5][0-9]|[0-9]):([0-5][0-9]|[0-9])'
  4.  
  5.  
  6. print(bool(re.match(timestamp_regex, '01:23:45'))) # True
  7. print(bool(re.match(timestamp_regex, '01:01:45'))) # True
  8. print(bool(re.match(timestamp_regex, '01:01:01'))) # True
  9. print(bool(re.match(timestamp_regex, '1:1:1'))) # True
  10. print(bool(re.match(timestamp_regex, '25:1:1'))) # False
Success #stdin #stdout 0.02s 9408KB
stdin
Standard input is empty
stdout
True
True
True
True
False