Reputation: 169
I have special characters in my XML and i am using Javascript function to replace it. I have found global search to replace in all my tags as.
var res = outputText.replace(/&/g,"&");
But i also want to replace </Product>
tag with <btn>Click NOW</btn></Product>
How can i replace this i am trying like
res = res.replace(/</Product>/g,"<btn>Click NOW</btn></Product>");
But it is giving me error invalid regular expression flag P
Upvotes: 1
Views: 71
Reputation: 150253
You need to escape the /
with \
:
res = res.replace(/<\/Product>/g,"<btn>Click NOW</btn></Product>");
//------------------^
Upvotes: 3