Sed should accept replacement strings that contain \1 and \2 and the like, for the sake of doing replacements. Currently, this is probably supported by $1, $2, etc. (but that's JS-syntax, not Unix-syntax).
sed(/my(.*)regex$/, '\\1 works', 'file.txt');
// probably the closest we can get to Unix sed's syntax without a breaking change:
// sed 's/my.*regex$/\1 works/' file.txt
This ties in closely with shx sed, since it doesn't currently support substitutions like this.