复制代码 代码如下:
<(?!((/?/s?li)|(/?/s?ul)|(/?/s?a)|(/?/s?img)|(/?/s?br)|(/?/s?span)|(/?/s?b)))[^>]+>
复制代码 代码如下:
private static string RemoveSpecifyHtml(string ctx) {
string[] holdTags = { "a", "img", "br", "strong", "b", "span" };//要保留的 tag
// <(?!((/?/s?li)|(/?/s?ul)|(/?/s?a)|(/?/s?img)|(/?/s?br)|(/?/s?span)|(/?/s?b)))[^>]+>
string regStr = string.Format(@"<(?!((/?/s?{0})))[^>]+>", string.Join(@")|(/?/s?", holdTags));
Regex reg = new Regex(regStr, RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.IgnoreCase);
return reg.Replace(ctx, "");
}
复制代码 代码如下:
<(?!((/?/s?li/b)|(/?/s?ul)|(/?/s?a/b)|(/?/s?img/b)|(/?/s?br/b)|(/?/s?span/b)|(/?/s?b/b)))[^>]+>
private static string RemoveSpecifyHtml(string ctx) {
string[] holdTags = { "a", "img", "br", "strong", "b", "span", "li" };//保留的 tag
// <(?!((/?/s?li/b)|(/?/s?ul/b)|(/?/s?a/b)|(/?/s?img/b)|(/?/s?br/b)|(/?/s?span/b)|(/?/s?b/b)))[^>]+>
string regStr = string.Format(@"<(?!((/?/s?{0})))[^>]+>", string.Join(@"/b)|(/?/s?", holdTags));
Regex reg = new Regex(regStr, RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.IgnoreCase);
return reg.Replace(ctx, "");
}
新闻热点
疑难解答
图片精选