Created
February 13, 2012 23:36
-
-
Save lennax/1821483 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
units = { | |
'day': 'd', | |
'hour': 'h', | |
'minute': 'm', | |
'second': 's', | |
} | |
# Matches only valid data (I hope) | |
# String format substitution to improve flexibility | |
valid = re.compile( | |
r"""\d+ %(day)s \s # 1 or more days | |
(1?\d | 2[0-3]) %(hour)s \s # 0-19 or 20-23 hr | |
[1-5]?\d %(minute)s \s # 0-59 min | |
[1-5]?\d %(second)s # 0-59 sec""" | |
% units, re.X) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment