Javascript 动态替换字符串中标记的所有实例

Javascript 动态替换字符串中标记的所有实例,javascript,regex,meteor,Javascript,Regex,Meteor,尝试使用Javascript中的RegExp替换电子邮件模板中的每个数据标记。以下是一封示例电子邮件: <h3>Appointment Scheduled</h3> <p>%clientName%,</p> <p>Your appointment with %userName% for %serviceName% is scheduled on %appointmentStart%. Please visit the following

尝试使用Javascript中的RegExp替换电子邮件模板中的每个数据标记。以下是一封示例电子邮件:

<h3>Appointment Scheduled</h3>
<p>%clientName%,</p>
<p>Your appointment with %userName% for %serviceName% is scheduled on %appointmentStart%. Please visit the following link if you would like to view or modify your appointment:</p>
<p style="margin-left: 25px;">%appointmentLink%<br></p>
只要换上你的

replaceAll(emailContent,match,replace);

您忘记保存修改


参见

Assign
replaceAll(emailContent,match,replace)
到某个变量(或添加
返回值
)。Doh!我必须再喝点咖啡。谢谢@Stribizev
replaceAll(emailContent,match,replace);
emailContent = replaceAll(emailContent,match,replace);