#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2010
    Posts
    4
    Rep Power
    0

    Expression not working as expected - newbie


    expression 1 : [ \ S ] * [ .] { 1 } [ 0 - 9 ] * [ . ] [ a - z , A - Z ] { 3 } - no grouping

    expression 2 : [ \ S ] * ( [ .] { 1 } [ 0 - 9 ] * [ . ] [ a - z , A - Z ] { 3 } ) - with grouping



    I want file names like this to be filtered, so they will not be processed:

    file 1 : MacOSXUpd10.6.2.dmg



    I want filenames like this to not be filtered, so they can be processed:

    file 2 : tmp_david.001.txt



    I thought grouping with parentheses would take care of it by using expression 2,

    but file 1 continues to not be filtered and therefore is processed when I don't want it to be processed.



    This is probably a pretty simple thing, but I am fairly new to regexp.



    Thanks,

    D
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    May 2007
    Posts
    765
    Rep Power
    929
    What exactly is the difference between the two file names that the regex is supposed to detect? Your regex says "anything DOT some numbers DOT three letters or comma" which matches both files (the presence or absence of capturing groups make no difference in how the regex matches btw).
    sub{*{$::{$_}}{CODE}==$_[0]&& print for(%:: )}->(\&Meh);
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2010
    Posts
    4
    Rep Power
    0
    Thanks for the quick response.
    I don't really know the difference between the expressions.
    I thought the grouping would match the entire grouping at once,
    instead of parts of it sequentially.

    I am looking for an expression that would filter out that extra dot between the the two outer dots.

    Thanks!
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2010
    Posts
    4
    Rep Power
    0
    I mean filter out the "file" which has the three dots in it.

    Thanks
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2010
    Posts
    4
    Rep Power
    0
    This seems to do it:
    [ \ S ] * [ .] { 1 } [ 0 - 9 ] [^ . ][0-9] [ a - z , A - Z ] { 3 }

    Thanks!
  10. #6
  11. kill 9, $$;
    Devshed Supreme Being (6500+ posts)

    Join Date
    Sep 2001
    Location
    Shanghai, An tSín
    Posts
    6,897
    Rep Power
    3886
    @davomar - are you using all that whitespace in your actual regular expression? I'd suggest improvements but I'm not certain if that's the form you're using it in.

IMN logo majestic logo threadwatch logo seochat tools logo