0

我有这样的字符串

<html>
    [[Wayfinder? &amp;startId=`0` &amp;outerClass=`art-hmenu` ]] &amp;
    &amp; 
</html>

我想改变&amp;里面的所有内容[[]]并将被替换为&

如何用 javascript 做到这一点?

4

1 回答 1

5
str.replace(/\[\[(.*)?]]/, function(match) {
    return match.replace(/&amp;/g, '&');
});

这是小提琴:http: //jsfiddle.net/Jtv5a/

于 2012-09-02T17:23:08.913 回答