On Wed, Apr 25, 2012 at 9:32 AM, Martin DeMello <martindemello / gmail.com> wrote:
> try this:
>
> File.open("destination.txt", "w") do |out|
>  ¨Âéì宿ïòåáã訢ïòéçéîáì®ôøô¢äï üìéîåü
> out.puts line
> if line =~ /YOUR_REGEX/
> out.puts "THE NEW LINE"
> elsif line =~ /YOUR_REGEX12/
> out.puts "THE NEW LINE12"
> end
>  ¨Âîä
> end

>> I am trying to add say 10 different triggers and add a new line after
>> that.

Another approach

RXS = {
  /YOUR_REGEX/ => "THE NEW LINE",
  /YOUR_REGEX12/ => "THE NEW LINE12",
}

File.open("destination.txt", "w") do |out|
  File.foreach("original.txt") do |line|
    out.puts line

    RXS.each do |rx, add|
      if rx =~ line
        out.puts add
        break # remove this if you want output for all triggers
      end
    end
  end
end

Kind regards

robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/