Interpolation question

Why does

text = <<ENDTEXT
this is an wibble
of stuff bobble

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,

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs