Hi, I'm looking for a function that can do the same thing as the strtr 
function in PHP (and possibly other languages, I don't know). That is, I 
would like to replace multiple parts of a strings simultaneously, so 
that you can (among others) swap strings:

strtr("AA BB", array("AA" => "BB", "BB" => "AA")); // "BB AA"

I've been trying to find a Ruby equivalent, but haven't so far. The tr 
functions in String only deal with single characters, and replace or 
gsub only deal with one replacement at a time.

Any functions that I missed, or perhaps a library with this 
functionality available?


thanks,

Jeroen Heijmans

-- 
Posted via http://www.ruby-forum.com/.