regular expression for [allchars]
reg = new RegExp("\\[.*?\\]", "g");
x = "[abc123.;.] this is more content";
console.log(x.replace(reg, "[contentreplacedwith]"));
If you use RegExp
constructor the there's no need to pass /
delimiters and the options like g
for global are a second argument.