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
It sounds like you're accessing group 1, when you need to be accessing group 0.
The groups in your regex are as follows:
\d{2}:\d{2}(AM|PM)
|-----| - group 1
|----------------| - group 0 (always the match of the entire pattern)
You can access the entire match via:
timePattern.match('02:40PM').group(0)