如何删除所有字符串,如下所示
<!-- ebanking log on -->
第二个例子
<!--
end the bottom row with 'peace of mind garuntee'
-->
示例文档: http: //pastebin.com/Y4gZdceK
所以它应该删除所有以开头<!--和结尾的字符串块-->
我尝试htmlagilitypack了内部文本,但它没有删除
如何删除所有字符串,如下所示
<!-- ebanking log on -->
第二个例子
<!--
end the bottom row with 'peace of mind garuntee'
-->
示例文档: http: //pastebin.com/Y4gZdceK
所以它应该删除所有以开头<!--和结尾的字符串块-->
我尝试htmlagilitypack了内部文本,但它没有删除
试试这个正则表达式:
<!--.*?-->
请注意:您必须使用RegexOptions.SingleLine更改点 ( .) 的含义,使其匹配每个字符(而不是除 之外的每个字符\n)。
编辑:代码示例
var myRegex = new Regex(@"<!--.*?-->", RegexOptions.Singleline);
string strTargetString = @"[sample text here]";
string replacedText = myRegex.Replace(strTargetString, "");