I am newbie in Regular Expressions.
I need to check this time 18:00(00:00, 01:00, 05:12, any time of this format) by regexp, is it correct or no.
Here is my variant:
/[0-9][0-9]:[0-9][0-9]/
Can I change [0-9][0-9] to something like 2*[0-9] ???
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you specifically want to match
18:00you should use/^\d{2}:\d{2}$/. The answers provided so far will matchaaa12:99ddd. The^and$are anchors and will instruct the regex to match specifically the given string.If you are after a 24 hour validation regular expression you could use this:
/^([01]?[0-9]|2[0-3]):[0-5][0-9]$/(taken from here).