function pattern(str, param, callback) { return str.replace(/\{([\w_]+)\}/g, function(tag, key) { return param[key] || tag; }); }