From: Guten Date: 2010-09-12T11:25:43+09:00 Subject: Re: .each skipping elements --0016367faf8b34ae27049006b238 Content-Type: text/plain; charset=ISO-8859-1 a = ["About us", "Blog", "Status", "Help", "TOS", "Privacy", "Are we missing an area?"] a.delete_if{|link| link =~ /(Blog|About Us|Status|Help|TOS|Privacy|Are we missing an area\?)/ } p a # return ["About us"] it works. maybe you need try {|link| link.text=~/../} Guten Tag. Linux Ruby facebook.com/gutenlinux Signature powered by WiseStamp On Sun, Sep 12, 2010 at 7:51 AM, David A. Black wrote: > 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 > > --0016367faf8b34ae27049006b238--