From: Lars Haugseth Date: 2012-04-25T17:38:05+09:00 Subject: Re: if if if statment On 04/25/2012 09:17 AM, fox foxmaster wrote: > 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. > Try using a case statement: File.open("destination.txt", "w") do |out| File.foreach("original.txt") do |line| out.puts line line2 = case line when /REGEX_1/ then "NEW_LINE_1" when /REGEX_2/ then "NEW_LINE_2" when /REGEX_3/ then "NEW_LINE_3" end out.puts line2 if line2 end end -- Lars Haugseth