I have input string in next format : 12:00am|1:20PM|9:30Pm
I need to have in output array of hours like : [12:00am, 1:20PM, 9:30Pm]
But before I shoudl match it with regex.
I have some regex to match AmPm hours and I tried to add |
to match full string
\b((1[0-2]|0?[1-9]):([0-5][0-9])([AaPp][Mm]))([|])?
. This regex matches string 12:00am|1:20PM|9:30Pm
but also matches string 12:00am|1:20PM}9:30Pm
which isn't correct.
Where is my mistake in my regex and how can I return expected array.
Thanks