String.prototype.startWith=function(str){
var reg=new RegExp("^"+str);
return reg.test(this);
}
String.prototype.endWith=function(str){
var reg=new RegExp(str+"$");
return reg.test(this);
}
String.prototype.format = function()
{
var args = arguments;
return this.replace(/\{(\d+)\}/g,
function(m,i){
return args[i];
});
}
var a = "I Love {0}, and You Love {1},Where are {0}! {4}";
alert(String.format(a, "You","Me"));
alert(a.format("You","Me"));
时间: 2025-01-18 01:15:29