Link to home
Start Free TrialLog in
Avatar of simonm_jp
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}$
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Agreed, assuming "11:47  AM" should be rejected.
Avatar of simonm_jp
simonm_jp

ASKER

For future reference, final answer was

^([1-9]|1[0-2]|0[1-9]):[0-5][0-9] ?[aApP][mM]$