How to represent more than one part of awk sub or gsub's matched string.

For a regexpr like "##code", if I want to insert a word between "##" and "code", I would want a way like VSCode's syntax in witch $1 represent the first part and $2 represent the second part

```
sub(/(##)(code)/, "$1before$2", str)

```

from awk's user manual, I found that awk use & to represent the whole matched string。 How can I represent one，two or more part in the matched string like VSCode.

> 
> sub(regexp, replacement [, target])
>  Search target, which is treated as a string, for the leftmost, longest substring matched by the regular expression regexp. Modify the entire string by replacing the matched text with replacement. The modified string becomes the new value of target. Return the number of substitutions made (zero or one).
> 
> 
> The regexp argument may be either a regexp constant (/…/) or a string constant ("…"). In the latter case, the string is treated as a regexp to be matched. See Computed Regexps for a discussion of the difference between the two forms, and the implications for writing your program correctly.
> 
> 
> This function is peculiar because target is not simply used to compute a value, and not just any expression will do—it must be a variable, field, or array element so that sub() can store a modified value there. If this argument is omitted, then the default is to use and alter $0.48 For example:
> 
> 
> str = "water, water, everywhere"
>  sub(/at/, "ith", str)
>  sets str to ‘wither, water, everywhere’, by replacing the leftmost longest occurrence of ‘at’ with ‘ith’.
> 
> 
> If the special character ‘&’ appears in replacement, it stands for the precise substring that was matched by regexp. (If the regexp can match more than one string, then this precise substring may vary.) For example:
> 
> 
> `{ sub(/candidate/, "& and his wife"); print }`
> 
> 
> changes the first occurrence of ‘candidate’ to ‘candidate and his wife’ on each input line. Here is another example:
> 
> 
> 

The user manual's link is [here](https://www.gnu.org/software/gawk/manual/html_node/String-Functions.html)