String.prototype.format = function(args) {
    var result = this;
    if (arguments.length > 0) {    
        if (arguments.length == 1 && typeof (args) == "object") {
            for (var key in args) {
                if(args[key]!=undefined){
                    var reg = new RegExp("({" + key + "})", "g");
                    result = result.replace(reg, args[key]);
                }
            }
        }
        else {
            for (var i = 0; i < arguments.length; i++) {
                if (arguments[i] != undefined&&arguments[i] != null) {
　　　　　 var reg= new RegExp("({)" + i + "(})", "g");
                    result = result.replace(reg, arguments[i]);
                }else{
                    var reg= new RegExp("('{)" + i + "(}')", "g");
                    result = result.replace(reg, null);
                }
            }
        }
    }
    return result;
}

String.prototype.strcontains=function(val){
    return  RegExp(val).test(this);
}
module.exports = String;