$ perl -E'say "xxx" =~ s/(*MARK:a)^.|(*MARK:c).$|(*MARK:b)./$REGMARK/gr' abc