fix string.replace duplication with matched group