I have a description from database coming like this :
"And here is the {{dog}} which is chasing the {{cat}}"
And instead of having {{dog}} I want to replace it by <span class="dog"/>
I tried this : My Attempt
I know how I can exctract but I don't know how to replace these parts only and then do my display.
Thanks you!
EDIT :
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]);
}
I want my final string to be :
And here is the <span class="dog"/> which is chasing the <span class='cat'/>
<span class="dog"/>. I just chose span but it would be an image or whatever.