From: Stefano Crocco Date: 2008-10-02T05:46:17+09:00 Subject: Re: simple gsub method Alle Wednesday 01 October 2008, Jack Smith ha scritto: > I have simplified my method for searching test to the following: > > def replacer(a, b) > x = "now is the time for all good men to come to the aid of their > country" > x.gsub(/#{a}/, b) > puts x > end > > puts "enter what to replace: " > j = gets > puts "enter replacer word: " > h = gets > > replacer(j, h) > > Can someone help me determine why gsub can't match my "a" value? > > thanks Strings returned by gets end in a newline, which doesn't exist in your string, so no match happens. To solve this, you can do j = gets.chomp and the same for h. I hope this helps Stefano