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
Use a non-delimited capture group (?:...):
(?:...)
>>> from re import findall >>> mystr = """ ... 02:40PM ... 12:29AM ... """ >>> findall("\d{2}:\d{2}(?:AM|PM)", mystr) ['02:40PM', '12:29AM'] >>>
Also, you can shorten your Regex to \d\d:\d\d(?:A|P)M.
\d\d:\d\d(?:A|P)M