Check out example codes for "replace strring by another string ruby". It will help you in understanding the concepts better.

Code Example 1

myString = "Welcome to JavaScript!"

myString["JavaScript"]= "Ruby"

puts myString
=> "Welcome to Ruby!"

Learn ReactJs, React Native from akashmittal.com