Brian Candler wrote in post #1029644:
>>> def transform2(str, hash)
>>>   str.split(/(@\w+)/).map { |x| x =~ /^@(.+)/ ? hash[$1] : x }
>>> end
> => nil
>>> transform2("Hello @bob!", hash)
> => ["Hello ", 42, "!"]

Very cool solution!  I didn't thought about using $1 after split. 
Awesome.
Thanks.

-- 
Posted via http://www.ruby-forum.com/.