From: "David A. Black" Date: 2010-09-12T08:51:23+09:00 Subject: Re: .each skipping elements Hi -- On Sun, 12 Sep 2010, Cameron Vessey wrote: > Thanks for the reply and I think I get it now > > if we delete element 50 > element 51 gets sloted into 50 > then the pointer moves to 51 never addressing the original 51..ok > > page.links.delete_if{|link| link =~ /(Blog|About > Us|Status|Help|TOS|Privacy|Are we missing an area?)/ (Note that the ? in that regex is a special character and will not match an actual question mark. It's a zero-or-one quantifier, operating on the "a" character before it.) > } > > I tried it .. it runs... no errors... It loops threw all the link > elements.. but never does any thing.. nothing gets deleted > > > I see how it should work ...but it doesn't Do you need to make it case insensitive? It definitely works: $ cat del.rb array = ["Keep1", "Blog", "Status", "Keep2", "TOS", "Help", "Keep3"] array.delete_if {|word| word =~ /Blog|Status|TOS|Help/ } p array $ ruby del.rb ["Keep1", "Keep2", "Keep3"] so something else must be going on. David -- David A. Black, Senior Developer, Cyrus Innovation Inc. The Ruby training with Black/Brown/McAnally Compleat Philadelphia, PA, October 1-2, 2010 Rubyist http://www.compleatrubyist.com