I’m trying to write a Javascript regexp replace function that allows me to replace every instance of some tags delimited by squared brackets with an arbitrary string.
function TestTags() {
var url = "test1=[A1]&test2=[A1]";
result = url.replace('\[A1\]', 'test');
console.log("result = " + result);
}
This works fine only for the first occurrence:
result = test1=test&test2=[A1]
I know it’s pretty silly but I haven’t be able to set the ‘g’ parameter to make it global. Can someone help me?
Thank you.
just add a g to it and use the
//syntax: