各位大侠,帮帮忙啊,怎么去掉 html标签中有带有“>”的标签啊?
解决方案 »
- 求一个正则表达式,输入字符串必须含有至少两个空格,其他不限
- JS读取数据库数据问题
- =========高分求sql语句
- 一个RGB颜色格式转16进制格式颜色格式的函数问题。。。
- 强烈建议高手们重新做一个控件来代替datagrid,这东西实在是太不好用了。
- 特效菜单的实现,请帮助
- 存储过程的问题?
- datalist 显示行的设置
- 急:datagrid怪问题:怎么每个纪录显示3遍?
- WPF之DataGrid的DataGridComboBoxColumn后台绑定
- 数据库外键设置后读取的问题。。
- |zyciis| Log4.NET 现在生成每天一个日志OK了,那如何让他日志超过指定大小时拆分呢?他的MaxFileSize无效
{
Regex htmlReg = new Regex(@"<[^>]+>", RegexOptions.Compiled | RegexOptions.IgnoreCase);
Regex htmlSpaceReg = new Regex("\\ \\;", RegexOptions.Compiled | RegexOptions.IgnoreCase);
Regex spaceReg = new Regex("\\s{2,}|\\ \\;", RegexOptions.Compiled | RegexOptions.IgnoreCase);
Regex styleReg = new Regex(@"<style(.*?)</style>", RegexOptions.Compiled | RegexOptions.IgnoreCase);
Regex scriptReg = new Regex(@"<script(.*?)</script>", RegexOptions.Compiled | RegexOptions.IgnoreCase); src = styleReg.Replace(src, string.Empty);
src = scriptReg.Replace(src, string.Empty);
src = htmlReg.Replace(src, string.Empty);
src = htmlSpaceReg.Replace(src, " ");
src = spaceReg.Replace(src, " ");
return src.Trim();
}
/// 过滤HTML字符 和 UBB代码
/// </summary>
public static string NoCode(string str)
{
if (str == null || str.Length == 0) return "";
str = Regex.Replace(str, @"\<(?<x>[^\>]*)\>", @"", RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"\[(?<x>[^\]]*)\]", @"", RegexOptions.IgnoreCase);
str = str.Replace(" ", " ");
str = str.Replace(">", ">");
str = str.Replace("<", "<");
str = str.Replace("\n", " ");
str = str.Replace("\r", "");
str = str.Replace("'", "");
return str;
}
htmlencode();
htmldecode();
utilityencode();
tobase64()
from base64()
for (m = r.Match(s); m.Success; m = m.NextMatch())
{
s= s.Replace(m.Groups[0].ToString(),"<B>" + m.Groups[2].ToString() + "</B>");
} r = new Regex(@"(\[i\])([ \t]*?)(\[\/i\])",RegexOptions.IgnoreCase);
for (m = r.Match(s); m.Success; m = m.NextMatch())
{
s= s.Replace(m.Groups[0].ToString(),"<I>" + m.Groups[2].ToString() + "</I>");
} r = new Regex(@"(\[U\])([ \t]*?)(\[\/U\])",RegexOptions.IgnoreCase);
for (m = r.Match(s); m.Success; m = m.NextMatch())
{
s= s.Replace(m.Groups[0].ToString(),"<U>" + m.Groups[2].ToString() + "</U>");
}