From: yermej Date: 2010-02-28T05:55:08+09:00 Subject: Re: Interpolation question On Feb 27, 12:58 pm, Dudebot wrote: > Why does > > text = < this is an wibble > of stuff bobble > ENDTEXT > > wibble = 2.0 > bobble = 3.0 > > newtext = text.gsub( /(.*?)<\/field>/, "#{\1}" ) > > puts newtext > > throw this error: > /test.rb:13: syntax error, unexpected $undefined > newtext = text.gsub( /(.*?)<\/field>/, "#{\1}" ) > > and not interpolate to produce > this is an 2.0 > of stuff 3.0 > > ? > > And how can I do that interpolation?  (adding \s to \1, e.g. \\1 > doesn't help) > > Many TIA, > Craig It seems that this will work: newtext = text.gsub(/(.*?)<\/field>/) {|match| eval $1} but I can't explain why what you attempted didn't work. Hopefully somebody else can explain what's going on. Jeremy