I'm trying to replace every word between %%
with a single word. Till now I tried this:
var string = "You chose %story% at %price%";
var rep = string.replace(/\%(.*)\%/g, "test");
console.log(rep);
but the result of rep
is actually
"You chose test"
while I want
"You chose test at test"
How can I achieve this? I though about implementing a recursive function but it sound pretty slow especially with multiple words