$ python -c 'import pcre2; print(pcre2.sub("(*MARK:a)^.|(*MARK:c).$|(*MARK:b).", "$*MARK", "xxx"))' abc