Ruby beauties: Multiple string replacements
Published in
1 min readFeb 25, 2016
Hey fellas!
Just check out this quick Ruby beauty today: multiple string replacements!
dynamic_string_that_may_have_multiple_typing_errors = “cheez burgs”dynamic_hash_containing_stuff_to_replace = {
‘cheez’ => ‘cheese’, ‘burgs’ => ‘burguers’
}dynamic_string_that_may_have_multiple_typing_errors.gsub(/cheez|burgs/, dynamic_hash_containing_stuff_to_replace)=> “cheese burguers”
Be happy & profit!