Strings In Depth16 / 19
Up next

gsub

s = "one fish two fish"
# gsub replaces all occurrences
puts s.gsub("fish", "cat")
# a block computes each replacement
puts "a1b2".gsub(/\d/) { |d| (d.to_i * 2).to_s }
What you're solving

replace every match