From: 7stud -- Date: 2011-05-12T08:31:56+09:00 Subject: Re: gsub and multiple-replacement You can also read the file line by line, and use a hash of replacements with gsub: replacements = { '{username}' => 'BOB', '{password}' => 'BOB-PASSWORD', '{userroot}' => 'BOB-USERROOT' } pattern = '{.*?}' File.open('out.xml') do |outfile| IO.foreach('in.xml') do |line| outfile.print gsub(/#{pattern}/, replacements) end end -- Posted via http://www.ruby-forum.com/.