I want to make user enter time in format "hh:mma" or "hh:mm a". I want to leave it to user the choice to enter space between mm & a. What can be the regular expression for this ?
1
-
now using /^(\d{1,2}):(\d{2})(:00)?([apAP][mM])?$/; – comeOnGetIt Jul 20 '14 at 0:46
0
Use ?
to make the preceding token optional, for example /colou?r/
matches color
and colour
. If you are struggling with the hh:mm part of the regex, this may help.
0
Something like the following should work
([01]?[0-9]|2[0-3]):([0-5]?[0-9])\s?(am|pm)