From: "F. Senault" Date: 2008-03-26T01:59:56+09:00 Subject: Re: remove regex matched line question Le 25 mars � 17:47, Ikuta Lin a �crit : > I wrote the code to query a txt file, and tried remove matched line like > as below but it not work as well, can someone help? > src.collect do |e| > if e=~/^(#)/ > src.delete(e) > end > end Yep. The collect method returns a copy of your source array, but doesn't modify it. OTOH, collect! does what you want. That being said, I'd use reject! myself : src.reject! { |e| e =~ /^#/ } HTH ! Fred -- Every finger in the room is pointing at me I wanna spit in their faces Then I get afraid of what that could bring I got a bowling ball in my stomach I got a desert in my mouth Figures that my courage would choose to sell out now (Tori Amos, Crucify)