I am trying to match something like [allchar] with a regular expression and be able to pull it out and replace it with other content
Here is what I am trying
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.
RegExp
/
g