From: Robert Klemme Date: 2005-11-22T21:37:25+09:00 Subject: Re: newbie question Vamsee Kanakala wrote: > Hi all, > > I'm playing with patterns: > > irb(main):001:0> name = "Jasmine" > => "Jasmine" > irb(main):002:0> phrase = "ja" > => "ja" > irb(main):003:0> name.sub(/ja/i, '**') > => "**smine" > irb(main):004:0> name.sub(/phrase/i, '**') > => "Jasmine" > > So, how do I tell sub that it should use the local variable phrase > instead of the string 'phrase' ? Try name.sub(/#{phrase}/i, '**') robert