I have the following function:
function myFunction(str, find, replace) {
var res = str.replace(new RegExp(find, 'g'), replace);
document.getElementById("demo").innerHTML = res;
}
Which simply will find and replace on a string that gets passed in. However lets say for example I want to have it find and replace something like [link here]. If I pass [link here] into the function it goes a bit mad and inserts % all over the place in the string. I'm guessing it does not agree with special chars? How can I get it to look for something inside [] ? Or should I just wrap it in something else like -link here-