------ art_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 <ikuta_lin / clousy.net>: > > 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 ile.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/. > > ------ art_7352_11485367.1206464025544--