I have a reminder app and I need to split the time like 3:30 a.m.. I used re module but I failed.
What I'm trying to do is split the time by colon in front of the words in list. But list has multiple words. Like a.m., am
The program should try the words until it gets the right match, and split the time by colon, such as hour and minute. 13:25 to [13, 25].
Here is an example:
import re
am = ['a.m.', 'am', 'ante meridiem']
timeinp = 'reminder for 3:30 am'
for a in am:
gettime = re.search(fr'\b\d?\d:\d\d\b {a}', timeinp).group(0)
gettime = re.split('[:]', gettime)
print(gettime)
This code gives me AttributeError: 'NoneType' object has no attribute 'group'.