From: Mateusz Tybura Date: 2008-03-26T01:53:35+09:00 Subject: Re: remove regex matched line question ------=_Part_7352_11485367.1206464025544 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Try to use String#chop or String#chomp 2008/3/25, Ikuta Lin : > > 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? > ------------------------ > code: > > src = File.open("./src.txt").readlines > puts src.inspect > src.collect do |e| > if e=~/^(#)/ > src.delete(e) > end > end > puts src.inspect > ------------------------- > txt > > #/etc/passwd > #/etc/shadow > /etc/group > > ------------------------ > problem > ["#/etc/passwd \r\n", "#/etc/shadow \r\n", "/etc/group \r\n"] > ["#/etc/shadow \r\n", "/etc/group \r\n"] > ------------------ > still available? > > -- > Posted via http://www.ruby-forum.com/. > > ------=_Part_7352_11485367.1206464025544--