Fix issue on string replacement

Target files may have special strings used by
replace() function [1].

So this commits changes "replace()" with an
alternative way to replace strings.

[1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace