From: Martin DeMello Date: 2012-04-25T16:32:46+09:00 Subject: Re: if if if statment 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 [see http://www.howtogeek.com/howto/programming/ruby/ruby-if-else-if-command-syntax/] martin On Wed, Apr 25, 2012 at 12:17 AM, fox foxmaster wrote: > Hi all, > > if I take this code. > > 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 > > it all works fine but if I do it like 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" >      if line =~ /YOUR_REGEX12/ >       out.puts "THE NEW LINE12" >     end >   end >  end > end > > It will only trigger on the first if statment. > > I am trying to add say 10 different triggers and add a new line after > that. > > Regards > /Fox > > -- > Posted via http://www.ruby-forum.com/. >