JSFiddle - React, Tailwind, and code Playground
HTML
<h3 id="start"></h3>
<h3 id="result" style="color:red"></h3>
JavaScript
var str = "{0} membership will start on {1} and expire on {2}.";
document.getElementById('start').innerHTML = str;
var arr = ['Jamie\'s', '11/27/14', '11/27/15'];
function personalizeString(string, replacementArray) {
return string.replace(/({\d})/g, function(j) {
return replacementArray[j.replace(/{/, '').replace(/}/, '')];
});
}
document.getElementById('result').innerHTML = personalizeString(str, arr);