[Solved] Generate string containing escaped interpolation


You have not the '\' in the string, it is added by the inspect: if you puts the string you will realize it:

asd = '<%= asd %>'.gsub(/<%=(.*)%-?>/, "\#{\\1}") #=> "\#{ asd }"

p asd #=> "\#{ asd }" <- this is `asd.inspect`, which is returned by `p`
"\#{ asd }" <- this is `asd.inspect`, which is printed by `p`

puts asd #=> nil <- this is `nil`, which is returned by `puts`
#{ asd } <- this is `asd.to_s`, and it is the actual string

1

solved Generate string containing escaped interpolation