Javascript String print_f()

Description

Javascript String print_f()


String.prototype.print_f = function() {
    var formatted = this;
    for (var i = 0; i < arguments.length; i++) {
        var regexp = new RegExp('\\{'+i+'\\}', 'gi');
        formatted = formatted.replace(regexp, arguments[i]);
    }/*from  w ww. j  a  va  2s . c  o  m*/
    return formatted;
};
String.prototype.format= function(){
 var args = arguments;
 return this.replace(/\{(\d+)\}/g,function(s,i){
   return args[i];
 });
}

function confirmdel(str){   
    return confirm(str);   
}



PreviousNext

Related