From: Andrei Caragea Date: 2009-07-06T23:36:24+09:00 Subject: several replacing problems Hello everyone, Take 1 xls file witch contains 2 columns. column A contains several "keywords" lets say: today, today+1, today+2 etc. and column B witch contains dates in yyyymmdd format 20090706, 20090707, 20090708 etc. i have another file (txt) witch contains a bunch of text.. including our "keywords" What i need to do is.. search in the txt file for the "keywords" and replace them with the dates and write the new content to a different file (same name and extension) in a different folder. The code is as follows: require 'rubygems' require 'roo' oo=Excel.new("data.xls") 1.upto(56000) do |line| template = oo.cell(line,'A') date = oo.cell(line,'B') date = date.to_s.gsub!('-','') date_template = { /\b#{template}\b(?=\s|$)/ => "#{date}"} Dir['*.txt'].each do |file_name| replace = File.read( file_name ) if template != nil date_template.each do |template, date| replace.gsub!( template, date ) end puts replace end File.makedirs("results") File::open("results/#{file_name}","w") do |file_name| file_name<