in reply to better way to get last named capture group

An alternative that feels cleaner, though (*MARK:NAME) is supported way fewer places than named captures:
$ perl -E'say "xxx" =~ s/(*MARK:a)^.|(*MARK:c).$|(*MARK:b)./$REGMARK/g +r' abc
$ python -c 'import pcre2; print(pcre2.sub("(*MARK:a)^.|(*MARK:c).$|(* +MARK:b).", "$*MARK", "xxx"))' abc