From: Robert Klemme Date: 2012-04-25T16:48:42+09:00 Subject: Re: if if if statment On Wed, Apr 25, 2012 at 9:32 AM, Martin DeMello wrote: > try this: > > 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" >   elsif line =~ /YOUR_REGEX12/ >     out.puts "THE NEW LINE12" >   end >  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/