My regular expression matches a formatted time string of the following types:
12:30
12:30 AM
12:30 pm
1:30
1:30 AM
((?:(?:[0-1][0-9])|(?:[2][0-3])|(?:[0-9])):(?:[0-5][0-9])(?::[0-5][0-9])?(?:\s?(?:am|AM|pm|PM))?)
I’m wondering how I can modify the expression to require the am/pm? Can anyone offer a hand?
Thanks!
Remove the last ‘?’:
((?:(?:[0-1][0-9])|(?:[2][0-3])|(?:[0-9])):(?:[0-5][0-9])(?::[0-5][0-9])?(?:\s?(?:am|AM|pm|PM)))