Object.extend(String, {
    format: function(format) {
        var args = (Array.from(arguments)).slice(1);
        return format.replace(/\{(\d+)\}/g, function(pat, index) {
          return args[Number(index)];
        });
    },

    escapeHTML: function() {
        return (
            this.replace(/&/g,'&amp;').
                 replace(/>/g,'&gt;').
                 replace(/</g,'&lt;').
                 replace(/"/g,'&quot;')
        );
    }
});
