From: fox foxmaster Date: 2012-04-17T18:00:30+09:00 Subject: Re: insert text after line "whatever" "Jesús Gabriel y Galán" wrote in post #1056852: > On Mon, Apr 16, 2012 at 9:09 PM, fox foxmaster > wrote: >> Hi all, >> >> Does anyone have a solution on how to either see the problems with the >> above code or a solution on how to do it with reading line by line and >> inserting the text after a specific line? > > Something like this should work: > > File.open("destination.txt", "w") do |out| > File.foreach("original.txt") do |line| > out.puts line > if line =~ /YOUR_REGEX/ > out.puts "THE NEW LINE" > end > end > end > > Jesus. So simple so beautiful :) Big thanks to you Jesus Regards Fox -- Posted via http://www.ruby-forum.com/.