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' ?


irb(main):013:0> phrase = /ja/i
=> /ja/i
irb(main):014:0> "Jasmine".sub(phrase, '**')
=> "**smine"

--
senate, n.  A body of elderly gentlemen charged with high duties
and misdemeanors.   --- Ambrose Bierce