John Smith wrote:
> Hi everyone,
> 
> I want to be able to run a program that will do a bunch
> of searches specified in an array of strings, and replace the
> first occurrence of those strings with strings specified on a
> second array for a given text file.
> 
> What would be the best way to do this?
> 
> Ted.

search=%w[one four]
replace=%w[1 4]
to_do = search.zip(replace)
File.open("file").each do |x|
  to_do.each { |y| x.gsub!(y[0],y[1]);  }
  puts x
end
-- 
Posted via http://www.ruby-forum.com/.