I\'m trying to match time formats in AM or PM.
i.e. 02:40PM 12:29AM
I\'m using the following regex
timePattern = re.compi
You're not capturing the Hour, minute fields:
>>> import re >>> r = re.compile('(\d{2}:\d{2}(?:AM|PM))') >>> r.search('02:40PM').group() '02:40PM' >>> r.search('Time is 12:29AM').group() '12:29AM'