Assitance with regular expression

Can someone assist with a regular expression for forcing this format? YYYY-MM-DD/XXXXX

The "Xs" are optional, only the "YYYY-MM-DD/" is required, but I need to allow the "Xs"

Thank you.
earwig75Asked:
Who is Participating?
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.

nemws1Database AdministratorCommented:
Are the Xs numbers?  If so (assuming perlre):

/\d\d\d\d-\d\d-\d\d(\/\d+)?/
0
earwig75Author Commented:
The Xs are optional so it shouldn't matter.
0
nemws1Database AdministratorCommented:
I ask because it depends on what language you trying to do this regex in.  Perl?  PHP?  Awk?  C#?

A very generic version would be something like this, but it might match too much.  Are there always 5 'X's?

/....-..-..(\/.+)?/

Open in new window

0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

earwig75Author Commented:
Sometimes there are NO Xs, sometimes there are 1 or 2 or 7. I'm using it in javascript. Thank you.
0
earwig75Author Commented:
So far neither of those seem to be working.
0
nemws1Database AdministratorCommented:
Try this - I was coding the "/" as optional, but now I see you require it.  I asked if the Xs were numbers because is does matter if I'm using \d, which only matches numbers.  Since you didn't answer, I'm going to assume the X's can be anything.

 
/\d\d\d\d-\d\d-\d\d\/(.*)?/ 

Open in new window

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
earwig75Author Commented:
Perfect, thank you.
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
Regular Expressions

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.