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 ?
Asked
Active
Viewed 2,638 times
1
-
now using /^(\d{1,2}):(\d{2})(:00)?([apAP][mM])?$/; – AdityaKapreShrewsburyBoston Jul 20 '14 at 00:46
4 Answers
0
Something like the following should work
([01]?[0-9]|2[0-3]):([0-5]?[0-9])\s?(am|pm)

Jonathon
- 15,873
- 11
- 73
- 92
0
I just put space in the pattern where I required space and if worked perfectly

AdityaKapreShrewsburyBoston
- 1,143
- 2
- 16
- 37