I have a complicated regEx inside a string replace and I want to use a variable called "tagname" instead of the word Category, but I don't know how to do this.
$("textarea").val().replace(/\<Category\>(.*)\<\/Category\>/gi, "<Category>TextVariable</Category>");
I have tried something like this, but it didn't work in the first parameter.
$("textarea").val().replace("/\<" + tagname + "\>(.*)\<\/" + tagname "\>/gi", "<" + tagname + ">" + TextVariable + "</" + tagname + ">");