mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
refactor(util) removeStrOneTime, ownRender
This commit is contained in:
parent
3239e38e8f
commit
b16dd92a48
1 changed files with 13 additions and 13 deletions
26
lib/util.js
26
lib/util.js
|
|
@ -513,23 +513,23 @@
|
|||
* @param pStr
|
||||
* @param pSubStr
|
||||
*/
|
||||
this.removeStrOneTime = function(pStr, pSubStr) {
|
||||
var lRet = Util.isString(pStr) && pSubStr;
|
||||
this.removeStrOneTime = function(str, substr) {
|
||||
var n, isArray,
|
||||
isString = Util.isString(str);
|
||||
|
||||
if ( lRet ) {
|
||||
var n = pSubStr.length;
|
||||
if (isString && substr) {
|
||||
n = substr.length;
|
||||
isArray = Util.isArray(substr);
|
||||
|
||||
if ( Util.isArray(pSubStr) )
|
||||
Util.fori(n, function(i) {
|
||||
lRet = pStr = pStr.replace(pSubStr[i], '');
|
||||
});
|
||||
if (!isArray)
|
||||
str = str.replace(substr, '');
|
||||
else
|
||||
lRet = pStr.replace(pSubStr, '');
|
||||
Util.fori(n, function(i) {
|
||||
str = str.replace(substr[i], '');
|
||||
});
|
||||
}
|
||||
else
|
||||
lRet = pStr;
|
||||
|
||||
return lRet;
|
||||
return str;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -602,7 +602,7 @@
|
|||
}
|
||||
|
||||
expr = firstChar + '.*' + secondChar;
|
||||
ret = Util.replaceStr(templ, expr, '', notEscape);
|
||||
ret = Util.replaceStr(ret, expr, '', notEscape);
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue