# Regex time pattern

I have the following time pattern:

``````// The pattern of times that accepts moments between 09:00 to 17:59
var TIME_PATTERN = /^(09|1[0-7]{1}):[0-5]{1}[0-9]{1}\$/;
``````

I need to modify the patter so it accepts  between 00:00 am and 11:59 pm  (so pretty much any time)
LVL 1
###### Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

OwnerCommented:
I'm curious why you have the {1} counts inserted there. It seems to me they could be omitted.

``````var TIME_PATTERN=/^((1[01])|(0[0-9])):[0-5][0-9]\$/;
``````

That assumes you aren't going to run into 24-hour time with hours 12-23. In that case, you'd want something more like:

``````var TIME_PATTERN=/^((2[0-3])|([01][0-9])):[0-5][0-9]\$/;
``````
Author Commented:
I actually need it to allow any times entered, from 00 in the morning to 11:59 at night.
Would the above work in that case ?

About the {1} counts I would rather leave them there, this is for a jquery forms validation and perhaps it needs it, not that familiar with it.
OwnerCommented:
In your example, you had 17:59, expressed as 24-hour time. So my second expression should work for you. The time 11:59 is still morning in this notation.

As for the {1} counts, you only applied them to some of the atoms, and their meaning is exactly the same as leaving them out.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Author Commented:
This is correct !  Works great thank you  !
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.