Not in the / / direct RE context, but in a " " string context.
Code:
gsub(("^" avar "|" bvar "$"), "", str)
With " " you can do string concatenation and all string functions. The disadvantage is the \ must be \ escaped (i.e. doubled) when used in (casted to) a RE context:
\\ in " "
\ in / /
And of course the delimiters must be \ escaped:
backslash" in " "
backslash/ in / /
(Have to write backslash here. I mean \ )