simonm_jp
asked on
RegEx for ShortTime string
Hi Experts,
The following regular expression validates the times in the format: "11:47AM" .... How to I change it to validate "11:47 AM" (The space is important because it needs to be in DateTime.ToShortTimeString format.
Thanks,
^([1-9]|1[0-2]|0[1-9]){1}( :[0-5][0-9 ][aApP][mM ]){1}$
The following regular expression validates the times in the format: "11:47AM" .... How to I change it to validate "11:47 AM" (The space is important because it needs to be in DateTime.ToShortTimeString
Thanks,
^([1-9]|1[0-2]|0[1-9]){1}(
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Agreed, assuming "11:47 AM" should be rejected.
ASKER
For future reference, final answer was
^([1-9]|1[0-2]|0[1-9]):[0- 5][0-9] ?[aApP][mM]$
^([1-9]|1[0-2]|0[1-9]):[0-