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
var text = "[abc123.;.] this is more content";
var replacewith = "[contentreplacedwith]";
reg = new RegExp("/\[{1}.*?\]{1}/g");
if(reg.test(text))
{
txt = $('#message').val().replace(text,'[' + replacewith + ']');
console.log(txt);
}
The result should be
[contentreplacedwith] this is more content