This is what I'm doing now:
text = text.replace(/{{contact first}}/gi, contact.first)
.replace(/{{contact last}}/gi, contact.last)
.replace(/{{contact name}}/gi, contact.first + ' ' + contact.last);
Is there a way of doing:
text = text.replace([
/{{contact first}}/gi,
/{{contact last}}/gi,
/{{contact name}}/gi
], [
contact.first,
contact.last,
contact.first + ' ' + contact.last
]);