不要匹配开始^和匹配末尾$
function replacer(word) { return 'hello'; } var newString = 'abc[你好]de[他]fg'.replace(/\[[^\u0000-\u00FF]{1,2}\]/gi, replacer);
不要匹配开始^和匹配末尾$