I have a string in Ruby:
sentence = \"My name is Robert\"
How can I replace any one word in this sentence easily without using complex code
You can try using this way :
sentence ["Robert"] = "Roger"
Then the sentence will become :
sentence = "My name is Roger" # Robert is replaced with Roger