In Regexes§

See primary documentation in context for Samemark

The :samemark or :mm adverb implies :ignoremark for the regex, and in addition, copies the markings from the matched characters to the replacement string:

given 'äộñ' {
    say S:mm/ a .+ /uia/;           # OUTPUT: «üị̂ã␤» 
}