refactor(util) replaceStr

This commit is contained in:
coderaiser 2014-05-12 07:59:00 -04:00
parent f5174234f4
commit 0c84ddc50c

View file

@ -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;
};
/**