我有来自数据库的描述如下:
"And here is the {{dog}} which is chasing the {{cat}}"
而不是让{{dog}}
我想用<span class="dog"/>
我试过这个:我的尝试
我知道如何提取,但我不知道如何仅更换这些部件然后进行展示。
谢谢!
编辑 :
var input = "And here is the {{dog}} which is chasing the {{cat}}";
var regex = /{{(.*?)}}/g;
var matches, output = [];
while (matches = regex.exec(input)) {
output.push(matches[1]);
}
我希望我的最后一个字符串是:
And here is the <span class="dog"/> which is chasing the <span class='cat'/>