regex for 2011-2-3

I tried /^\d{1,2}-\d{1,2}-\d{4}$/

but it fails.

I then tried /^\d{1,2}/-\d{1,2}/-\d{4}$/

also failed
bhomassAsked:
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.

Terry WoodsIT GuruCommented:
Try:
/^\d{4}-\d{1,2}-\d{1,2}$/
0

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.

Start your 7-day free trial
brendanmeyerCommented:
^\d{4}[/-]\d{1,2}[/-]\d{1,2}$
0
micropc1Commented:
Maybe try something like...

/^[2][0][0-1][0-2][. /-][0-1][0-2][. /-][0-3][0-9]$/
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

bhomassAuthor Commented:
sorry, my bad. the problem was else where. I think my regex was good.
0
bhomassAuthor Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for bhomass's comment #37708042

for the following reason:

bad question on my part.
0
Terry WoodsIT GuruCommented:
I object to accepting your own comment as the solution. The date format as given in the question title was clearly different to what would match in your own patterns (yours expected the year at the end). Experts provided correct solutions to the given problem and they should be accepted.
0
micropc1Commented:
I also object - adequate solutions were given. Looking at bhomass's past activity I'm seeing a pattern here...moderator might want to look at this...
0
bhomassAuthor Commented:
I wrote the wrong pattern. was doubly bad on my part. what I should have written was
What I meant to post was /^\d{4}-\d{1,2}-\d{1,2}$/. Same as what an experts suggested.

I could give you credit for that if you feel justified. But the problem I was having was not this one. I thought maybe the - character was what caused my problems, but it was not. I don't believe the [/-] modification was a good suggestion. Would you like to make a case that it was?

I would not go where I have pattern of anything. each post has its own history, and I have given credits whenever the experts had a valid case.
0
micropc1Commented:
Yes - sorry. I see that I was mistaken and I retract my objection - have a good day.
0
Terry WoodsIT GuruCommented:
I believe points are justified. 3 solutions were offered to the given problem - I recommend a split between them as you see fit.
0
bhomassAuthor Commented:
not exactly the answer I was looking for. expert pointed a mis-typed expression. the real answer is it is ok to have the '-' char to represent itself in a regex expression
0
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
JavaScript

From novice to tech pro — start learning today.