简体   繁体   English

匹配字符串中的Javascript正则表达式

[英]Javascript Regex inside matched string

I have string like this 我有这样的字符串

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

I want to change all &amp; 我想更改所有&amp; that inside of [[ and ]] will be replaced by & [[]]内部将由&替换

How to do that with javascript? 如何使用javascript做到这一点?

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

Here's the fiddle: http://jsfiddle.net/Jtv5a/ 这是小提琴: http : //jsfiddle.net/Jtv5a/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM