1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

please help with regular expressions

Discussion in 'T&T - Miscellaneous' started by Frank, Apr 29, 2012.

  1. Frank

    Joined:
    Aug 2, 2011
    Messages:
    258
    Likes Received:
    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.
     
  2. JohnQSmith

    Joined:
    Jan 19, 2011
    Messages:
    559
    Likes Received:
    7
    I'm not sure which version you are looking for...

    First you say
    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
    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.
     
  3. Frank

    Joined:
    Aug 2, 2011
    Messages:
    258
    Likes Received:
    4
    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.
     

Share This Page