minor `replace` func improvement: preserve quote char and escaped flag.