Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Ruby
Ruby equivalent for PHP's strtr?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Jeroen Heijmans, post: 4508550"] 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 [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Ruby
Ruby equivalent for PHP's strtr?
Top