有一段字符串类似“<OL><LI><STRONG>wwwwwww</STRONG><BR>wwwwww<BR><STRONG>wwwwwww</STRONG><BR><STRONG>
”这样的字符串,我想把这段字符串中的所有标签全部去掉,这剩下所有的wwwww,如何实现,大仙们给点指导
------最佳解决方案--------------------------------------------------------
StreamReader reader = new StreamReader("c:\\temp\\1.txt",Encoding.Default);
string source = reader.ReadToEnd();
Regex reg = new Regex(@"(?is)(?<=>)[^<]+(?=<)");
MatchCollection mc = reg.Matches(source);
foreach (Match m in mc)
{
MessageBox.Show(m.Value);
}
------其他解决方案--------------------------------------------------------
http://blog.csdn.net/gulijiang2008/article/details/7190281
------其他解决方案--------------------------------------------------------
这个用HtmlAgilityPack会非常简单。
------其他解决方案--------------------------------------------------------
public static string ReplaceHtmlMark(string HtmlString)
{
string[] RegexString = {
@"style='.*?'",
@"class='.*?'",
@"<param.*?>(</param>)?",
@"<embed.*?>(</embed>)?",
@"<object.*?>(</object>)?",
@"<strong.*?>(</strong>)?",
@"<span.*?>(</span>)?",
@"<p.*?>(</p>)?",