Implement backreferences in replacement strings.