C# 正则表达式匹配URL(如果不在html注释行中)

C# 正则表达式匹配URL(如果不在html注释行中),c#,regex,C#,Regex,我只想在“”不是html注释时匹配它 所以不要和这条线匹配 <!--<p><iframe src="https://www.mysite/embed/M7znk1c-ay0" width="854" height="480" frameborder="0" allowfullscreen="allowfullscreen"></iframe>--> <article class="art-post"><div class="ar

我只想在“”不是html注释时匹配它

所以不要和这条线匹配

<!--<p><iframe src="https://www.mysite/embed/M7znk1c-ay0" width="854" height="480" frameborder="0" allowfullscreen="allowfullscreen"></iframe>-->
<article class="art-post"><div class="art-postcontent clearfix"><div class="art-article"><p><iframe  src="https://www.mysite/embed/M7znk1c-ay0" ></iframe></p>

但要符合这条线

<!--<p><iframe src="https://www.mysite/embed/M7znk1c-ay0" width="854" height="480" frameborder="0" allowfullscreen="allowfullscreen"></iframe>-->
<article class="art-post"><div class="art-postcontent clearfix"><div class="art-article"><p><iframe  src="https://www.mysite/embed/M7znk1c-ay0" ></iframe></p>


我尝试了这个模式,你几乎做对了。正确的正则表达式是HTML不是正则的,所以使用正则表达式来解析HTML可能不是一个好主意。。。 @csabinho的答案
^(?!”;
var res=Regex.Replace(输入,模式,“,RegexOptions.Singleline);
然后使用一个简单的模式从的结果中提取URL

可能的重复项。在您的情况下不需要正则表达式。