From: Axel Etzold Date: 2007-06-30T03:58:30+09:00 Subject: Re: newbie questions on processing numerical data from text files > > interesting_text.delete_if{|line| /(r|R)uby/.match==nil} > > > > removes all lines that don't contain the string Ruby or ruby, > > for some reason this doesn't work for me. I get an error message: > ArgumentError: wrong number of arguments (0 for 1) > > > if i replace this argument with something based on line numbers > rather than regexp, it's fine. Is the Regexp wrong? You're right. The line should read: interesting_text.delete_if{|line| /(r|R)uby/.match(line)==nil} > > > > > >> and change a value > > old_value=1.2 > > new_value=2.4 > > > > interesting_text.sub!(old_value.to_s,new_value.to_s) > > > > I can't get that to work either : > NoMethodError: private method `sub!' called for # > .. and again .. sub, gsub, sub!,gsub! are for Strings ... so either: interesting_text=IO.readlines(file_name).to_s interesting_text.sub!(old_value.to_s,new_value.to_s) or , if, each line is to be processed separately, interesting_text=IO.readlines(file_name) new_text=interesting_text.each{|line| line.sub(old_value.to_s,new_value.to_s)} Sorry for the confusion. Best regards, Axel > > > > > > > > Best regards, > > > > Axel > > > The rest works fine, thanks again! > > baptiste > > -- Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! Ideal f�r Modem und ISDN: http://www.gmx.net/de/go/smartsurfer