diff --git a/lib/util.js b/lib/util.js index 9babde0a..11a393e9 100644 --- a/lib/util.js +++ b/lib/util.js @@ -488,22 +488,23 @@ /** * function replase pFrom to pTo in pStr - * @pStr - * @pFrom - * @pTo - * @pNotEscape + * @param str + * @param from + * @param to + * @param notEscape */ - this.replaceStr = function(pStr, pFrom, pTo, pNotEscape) { - var ret = pStr; + this.replaceStr = function(str, from, to, notEscape) { + var isStr = Util.isStr(str), + regExp = new RegExp(from, 'g'); - if (pStr && pFrom) { - if (!pNotEscape) - pFrom = Util.escapeRegExp(pFrom); + if (isStr && from) { + if (!notEscape) + from = Util.escapeRegExp(from); - ret = pStr.replace(new RegExp(pFrom, 'g'), pTo); + str = str.replace(regExp, to); } - return ret; + return str; }; /**