日期:2014-05-17 浏览次数:20481 次
protected string ConvertGettext(string str)
{
Regex regex = new Regex(@"<[^/>]+>(
------解决方案--------------------
\ \;)*</[^>]+>");
while (true)//循环替换,防止元素嵌套
{
str = regex.Replace(str, "");
if (!regex.IsMatch(str))
break;
}
return str;
}
ConvertGettext("<div> <p> </p>、<p> </p>、<p></p></div><div><span> <a> </a> </span></div><div>11111111</div>");
string str = "<div> <p> </p>、<p> </p>、<p></p></div><div><span> <a> </a> </span></div><div>11111111</div>";
Regex reg = new Regex(@"<(?<bq>[^>]+)>(
------解决方案--------------------
\s)*</\k'bq'>");
MatchCollection mc = reg.Matches(str);
while (mc.Count > 0)
{
foreach (Match m in mc)
{
str = str.Replace(m.Value, "");
}
mc =&n