I want to replace the text which is inside the brackets matched by regex (The first group of regex)
In other words i try to catch a string like "[SomeText][1]" and replace the number 1 with number 2 in it. The code below is replacing all the string with 2 which i dont want.
regex = new RegExp("\\[.*\\]\\[(1)\\]");
textarea.val().replace(regex, 2);
SomeText is changing. So replace("[SomeText][1]", "[SomeText][2]") does not work.
textarea.val().replace(/\[1\]$/, '[2]');?[1]since there is a$