From: "Jesse B." Date: 2010-03-27T01:17:34+09:00 Subject: Re: index of string from beginning of line vs beginning of file Thank You Robert, I tried running this and unfortunately it shows the line break (newline) with or without the leading space before the "comment". So I think Jesus is unto something with the "joined the array before writing it because puts with an array prints a newline between each element." Now I just need to figure out how to have it not do the newline when there are spaces before the "comment" thanks for your time. Robert Klemme wrote: > 2010/3/25 Jes�s Gabriel y Gal�n : >>> closing text >>> closing text >> - I added an optional \n at the beggining of the matched area to cover >> that case, although there might be other corner cases. >> - I joined the array before writing it, because puts with an array >> prints a newline between each element. > > If you slurp in the whole file anyway then you can do > > content = File.read "input.txt" > content.gsub! %r{--/.*?/--}m, '' > > File.open "output.txt", "w" do |out| > out.write content > end > > Kind regards > > robert -- Posted via http://www.ruby-forum.com/.