try this: string = "I am sold" string.sub!('old','new').reverse!; puts string It works. If string didn't contain the word 'old' then it will fail. Is that a nice behavior? Can it be changed to work on whatever input?