我正在尝试将 [allchar] 之类的内容与正则表达式匹配,并能够将其拉出并用其他内容替换
这是我正在尝试的
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);
}
结果应该是
[contentreplacedwith] this is more content