如我有字符串
var mothed = "OnLoad OnFocus OnValid OnShow";
var remove = "OnFocus OnShow";
var finally = removeMothed(mothed,remove);//最后为"OnLoad OnValid";谢谢其实要的功能就像是$.removeClass()这样的功能,那这里面的removeMothed方法要怎么写呢谢谢
var mothed = "OnLoad OnFocus OnValid OnShow";
var remove = "OnFocus OnShow";
var finally = removeMothed(mothed,remove);//最后为"OnLoad OnValid";谢谢其实要的功能就像是$.removeClass()这样的功能,那这里面的removeMothed方法要怎么写呢谢谢
var reg=re.split(" ").join("|");
return me.replace(new RegExp(reg,"g"/*如果不区分大小写,这里改为"gi"*/),"");
}
var mothed = "OnLoad OnFocus OnValid OnShow";
var remove = "OnFocus OnShow";
var fina = removeMothed(mothed,remove);//
alert(fina);
{
var m;
$(remove.split(' ').each(function()
{
m = method.split(' ');
var index = $(m).index(this);
if(index >= 0 && index < m.length) m.splice(index,1);
});
return m.join(' ');
}
//var reg="\\b"+re.replace(/\s+/g," ").split(" ").join("\\b|\\b")+"\\b";//将多个空格替换为一个,再以空格拆分
var reg="\\b"+re.replace(/\s+/g,"\\b|\\b")+"\\b";
return me.replace(new RegExp(reg,"g"/*如果不区分大小写,这里改为"gi"*/),"");
}
var mothed = "OnLoad OnFocus OnValid OnShow";
var remove = "OnFocus OnShow";
var fina = removeMothed(mothed,remove);//
alert(fina);