Forum Moderators: coopster
HH:MM AM or PM or am or pm
Can anyone help me out here? I've tried writing my own about 50 times and I cant get it to work, and I can't find any on the internet that work correctly.
Any help is greatl appreciated. Thank you very much.
19:01 am...would be incorrectly accepted. We'll have to expand our pattern to catch that. Below are two similar regular expressions, the only difference being how many spaces must be present between the digits and the "am/pm".
00:69 am
// Must have one and only one space...
"/(0[1-9]¦1[0-2]):[0-5][0-9] ([ap]m¦[AP]M)/"
// Must have at least one space...
"/(0[1-9]¦1[0-2]):[0-5][0-9]\s+([ap]m¦[AP]M)/"
Don't forget that the vertical pipe "¦" symbol is modified by posting in this forum -- you must replace it with the solid vertical pipe character from your keyboard.