From: Clement Ow Date: 2008-05-15T12:05:01+09:00 Subject: Re: Handling of arrays >> I'm not sure if I'm understanding you correctly, but you can tweak the >> regexps so that they actually match what you want. If you want >> to deselect only the files that start with 2007 you can do this: >> >> irb(main):001:0> a = %w{20071212 20073445 risk20072341} >> => ["20071212", "20073445", "risk20072341"] >> irb(main):003:0> a.reject {|x| x =~ /\A2007/} >> => ["risk20072341"] > > Oh yea, i did try this but it doesnt work, somehow *scratches head* It > just shows all files to be moved, and it obviously did not carry out the > exceptions. But if it's done this way, there wont be any point in keying > in the various different exceptions alr, hence i got stuck. :/ Oh i realise what was wrong in the matching of this regexp, because in: >files = exceptions_by_path[path].inject(Dir.glob("#{path}/*")) >{|result, >ex| result.reject{|x| x =~ Regexp.new(ex)}} >end After much playing around with this statement,result here is the whole path name, which apparently doesnt match the filename itself, hence making /\A2007/ not able to work. (prolly need to use File.basename(result)) But can you do me a favour by explaining what this statement means as I dunno how come some variables assigned to certain commands etc.? Thanks! -- Posted via http://www.ruby-forum.com/.