please help with regular expressions

Aug 2, 2011
258
4
Berlin, Germany
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.
 
Jan 19, 2011
614
15
Norman, OK
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.
 
Aug 2, 2011
258
4
Berlin, Germany
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.