minor `replace` func improvement: preserve quote char and escaped flag.
minor `%` func improvement: preserve quote char and escaped flag, updated tests.
Merge pull request #1884 from seven-phases-max/replace-func-improvement

Minor `replace` and `%` funcs improvement.