I am writing a Python 3 program that keeps track of hours spent with a client. One way to log hours is to use a string like Client 9:35am 1:35pm
where the first time is the beginning and the second is the end.
To extract the times from the string, I used regex101.com to construct the following pattern:
r"[01]?[0-9]:[0-5][0-9]\s*([Aa][Mm]?|[Pp][Mm]?)"
When testing it on the above example with regex101, it correctly identifies the two times as two separate matches. However, when trying to use the pattern with Python, the list re.findall returns only contains AM or PM:
re.findall(r"[01]?[0-9]:[0-5][0-9]\s*([Aa][Mm]?|[Pp][Mm]?)", "Client 9:35am 1:35pm")
['am', 'pm']
How can I change this so that matches contain the whole time?