As you may (or not) know, you can reference a capture group with:
$1
1 being the group number.
In the same way, you can reference a named capture group with:
${name}
\{name}
g\{name}
Let's take the preceding example and replace the matches with
The hero of the story is a ${subject}.
T...