Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

please help with regular expressions

Aug
258
4
Hello,

I'm not familiar with regular expressions.
I want fo find all directories which contain the years 2000-2012 in its name and have
a " ", "-" or "_" before the date-string, e.g. " 2009", "-2011" or "_2008".
So far I tried

dir /s /a:d *20[0-1][0-9]*

which is working well.
But I have no idea how to exclude the above mentioned three leading characters.
Any help would be appreciated.
 
I'm not sure which version you are looking for...

First you say
I want fo find all directories which contain the years 2000-2012 in its name and have a " ", "-" or "_" before the date-string
For that, here's what you need.
Code:
dir /s /a:d "::.*[ _-]20(0[0-9]|1[0-2]).*"

Then you go on to say
But I have no idea how to exclude the above mentioned three leading characters.
So here's the solution for that.
Code:
dir /s /a:d "::.*[^ _-]20(0[0-9]|1[0-2]).*"

Edit: hang on... that's wrong. Those will give you 2000-2019. One sec and I'll rewrite them.
Edit2: Fixed.
 
John, excuse me - I was not precise enough.
You're right, my 2nd statement brings a litte bit confusion into my 1st statement ;-)
And (if I'm still at my job for the next years) I also want to find the upcoming years.
Thank you.
 
Back
Top