我有这个字符串:
var text = "Altough I am the eldest son, they stil see me as kdi.";
这个数组:
var errors = ["Altough", "stil", "kdi"];
我想替换句子中数组中的单词,所以文本看起来像这样:
<span class="error">Altough</span> I am the eldest son, they <span class="error">stil</span> see me as <span class="error">kdi</span>.
我必须使用正则表达式,还是 javascript replace() 函数可以?