Format String By Named Values
by Liam Talbot
JavaScript
if (!String.prototype.FormatUrlByNames) {
String.prototype.FormatUrlByNames = function (replacements) {
return this.replace(/{\w+}/g, function (all) {
return replacements[all.substring(1, all.length - 1)] || all;
});
};
}
alert("http://localhost:1824/api/clients/{clientNumber}/details".FormatUrlByNames({"clientNumber":12345}));