我正在尝试在下面的HTML上执行正则表达式替换。我正在使用一个现有的(我没有写它并且没有真正理解它)正则表达式模式忽略HTML标记内的任何内容,但我需要它也忽略脚本标记之间的任何内容。模式是(?<!<[^>]*)(diversity|and|inclusion)
。问题是,javascript中的和'playerBrandingId'
正在匹配并最终被替换。如果重要,我正在使用C#。 You can see what I get here.
<p>When it comes to building more diverse and inclusive workforces, the sports industry is already a leader, but it can do much more. One of the ways SBD/SBJ is focusing on diversity and inclusion is by talking to business leaders about what the industry can do better. In our first video in the “SBJ Diversity and Inclusion” series, we hear from execs working in leagues, technology, recruitment and academia.</p>
<div class="article-offset-block article-video article-offset-block--half">
<div class="u-vr2">
<div id='video-F17F523A70EB43ECAF54DF46144835B4'></div>
</div>
</div>
<script>
var playerParam = {
'pcode': 'poeXI63BtIsR_ugBoy3Z6X8KfiMo',
'playerBrandingId': 'video-F17F523A70EB43ECAF54DF46144835B4',
'autoplay': false,
'loop': false
};
OO.ready(function () { window.ppF17F523A70EB43ECAF54DF46144835B4 = OO.Player.create('video-F17F523A70EB43ECAF54DF46144835B4', 'w5cW9qZTE6qRRDqfBdi861XWJTXci9uE', playerParam); });
</script>
编辑:
模式是由用户的查询生成的,因此模式可以包含单词window
或player
,当我更改模式以包含\b
时,它将在javascript中匹配:(?<!<[^>]*)\b(window|player|and)\b