[英]Javascript regular expression to validate time format “09:15 AM”
我尝试使用以下正则表达式,但无法正常工作。
/^([01]?[0-9]|2[0-3]):[0-5][0-9]{2}(AM|PM)/
You can try using this regex: 您可以尝试使用此正则表达式:
^(0?[1-9]|1[012])(:[0-5]\d) [APap][mM]$
你可以这样尝试
/^[1-12]:[0-59](A|P)M$/i
You are missing space before AM|PM and there is unnecessary {2}
The following changes works for me: 您在AM | PM之前缺少空格,没有必要的
{2}
以下更改对我有用:
^([01]?[0-9]|2[0-3]):[0-5][0-9] (AM|PM)
On the string 在弦上
09:15 AM
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.