diff --git a/lib/util.js b/lib/util.js index aa16333c..813ea2d4 100644 --- a/lib/util.js +++ b/lib/util.js @@ -494,14 +494,15 @@ * @param notEscape */ this.replaceStr = function(str, from, to, notEscape) { - var isStr = Util.isString(str), - regExp = new RegExp(from, 'g'); + var regExp, + isStr = Util.isString(str); if (isStr && from) { if (!notEscape) from = Util.escapeRegExp(from); - str = str.replace(regExp, to); + regExp = new RegExp(from, 'g'); + str = str.replace(regExp, to); } return str;