Rumah > Soal Jawab > teks badan
<script>
function replacer(word) {
return 'hello';
}
var newString = 'abc[你好]de[他]fg'.replace(/^\[[^\u0000-\u00FF]{1,2}\]$/gi, replacer);
alert(newString)//todo:为什么这里显示的不是hellohello,我想把[你好][他]替换成hello
</script>
天蓬老师2017-05-19 10:37:44
Jangan padankan permulaan^ dan padankan penghujung$
function replacer(word) {
return 'hello';
}
var newString = 'abc[你好]de[他]fg'.replace(/\[[^\u0000-\u00FF]{1,2}\]/gi, replacer);