From: 7stud -- Date: 2011-05-12T08:59:23+09:00 Subject: Re: gsub and multiple-replacement And here is a xml parsing solution: require 'rexml/document' include REXML xml =< 'BOB', '{password}' => 'BOB-PASSWORD', '{userroot}' => 'BOB-USERROOT' } pattern = '{.*?}' doc = REXML::Document.new(xml) XPath.each(doc, '//string') do |element| text = element.text element.text = text.gsub(/#{pattern}/, replacements) end puts doc.to_s Note that you are using an unfortunate character in the string: domain\{userroot} A backslash has a special meaning in ruby strings. You need to change that to a forward slash(or escape it). -- Posted via http://www.ruby-forum.com/.