javascript - JS - Regular Expression for 12hr Time Matching -


i attempting take regular expression being used in java application , use javascript.

(1[012]|[1-9]):[0-5][0-9](\\s)?(?i)(am|pm) 

however, running issues. getting syntaxerror: invalid quantifier error. escaped ? , ended with

(1[012]|[1-9]):[0-5][0-9](\s)?(\?i)(am|pm) 

however, when run following test, not matching properly:

"1:00 am".match(/(1[012]|[1-9]):[0-5][0-9](\s)?(\?i)(am|pm)/) 

this regex should matching “1:00am”, “1:00 am”, ”1:00 am”

where going wrong?

try

"1:00 am".match(/(1[012]|[1-9]):[0-5][0-9]\s?(am|pm)/i) 

the ignore case flag i should @ end of regex


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -