From: Peter Marks Date: 2007-08-28T19:10:16+09:00 Subject: Re: Conducting Regular Expressions on a text file J-H Johansen wrote: > You could also create a Hash for placeholder => word in case you have > a lot of things that needs to be changed. Thanks J-H, that works fine. I do have a a lot of these however, so a hash is probably the be the way to go. This is what I'll be doing: rehash = { "placeholder" => "word", "placeholder2" => "other", } File.open('test.txt') do |file| File.open("sink.rtf", "w") do |sink| while line = file.gets sink.write line.gsub(/\[#([^#]*)#\]/){ rehash[$1] } end end end -- Posted via http://www.ruby-forum.com/.