Maison > Questions et réponses > le corps du texte
<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
Ne correspondez pas au début^ mais correspondez à la fin$
function replacer(word) {
return 'hello';
}
var newString = 'abc[你好]de[他]fg'.replace(/\[[^\u0000-\u00FF]{1,2}\]/gi, replacer);