读取日志内容前50个字符出错 我做了一个博客 日志列表里显示的日志的标题和日志内容的前50个字符开始测试都没问题 可是有一个日志我把图片放前面了 也就是说一开始是图片然后才是字符结果日志列表里就只有一个标题 日志内容的前50个字符读不出来了怎么才能解决这个问题谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我写了一个可是不管用我是用FCKeditor1.Value 直接存进数据库的我去看了一下数据库里面没有 img这种东西 怎么办呀content.Replace("<img[^>]*>",""); 在显示50个数之前调用这个函数 public static string wipescript(string html) { System.Text.RegularExpressions.Regex regex0 = new System.Text.RegularExpressions.Regex(@"<(.[^>]*)>", System.Text.RegularExpressions.RegexOptions.IgnoreCase); System.Text.RegularExpressions.Regex regex1 = new System.Text.RegularExpressions.Regex(@"(\<.[^\<]*\>)", System.Text.RegularExpressions.RegexOptions.IgnoreCase); System.Text.RegularExpressions.Regex regex2 = new System.Text.RegularExpressions.Regex(@"(\<\/[^\<]*\>)", System.Text.RegularExpressions.RegexOptions.IgnoreCase); System.Text.RegularExpressions.Regex regex3 = new System.Text.RegularExpressions.Regex(@"<(.[^>]*)>", System.Text.RegularExpressions.RegexOptions.IgnoreCase); System.Text.RegularExpressions.Regex regex4 = new System.Text.RegularExpressions.Regex(@"<iframe[\s\s]+</iframe *>", System.Text.RegularExpressions.RegexOptions.IgnoreCase); System.Text.RegularExpressions.Regex regex5 = new System.Text.RegularExpressions.Regex(@"<frameset[\s\s]+</frameset *>", System.Text.RegularExpressions.RegexOptions.IgnoreCase); System.Text.RegularExpressions.Regex regex6 = new System.Text.RegularExpressions.Regex(@"<(\S*?)[^>]*>.*? </\1> | <.*?/>", System.Text.RegularExpressions.RegexOptions.IgnoreCase); html = regex0.Replace(html, ""); html = regex1.Replace(html, ""); html = regex2.Replace(html, ""); html = regex3.Replace(html, ""); html = regex4.Replace(html, ""); html = regex5.Replace(html, ""); html = regex6.Replace(html, ""); return html; } //清除html标记并截取前50个字符 protected string FormatStr(string str) { str = System.Text.RegularExpressions.Regex.Replace(str, "<[^>]+>", ""); str = str.Length > 50 ? str.Substring(0, 50) + "..." : str; return str; } [jquery] 限制fileupload 文件大小 急,急,急,救急 。用户控件泛化(今天结贴) 如何用JAVASCRIPT控制弹出界面大小 NickLee大大指点一下NickLee.Web.UI.Menu这个控件 如何将一个textbox里面的得到内容写入到sql server2000数据库中? ajax.actionlink出现的问题,求大神 刷新 ajax 要是中间的alert注销页面长时间加载 这是什么问题 大家编辑ASP.NET一般是在哪里编辑? MVC权限设计实现 做.net的困惑 帮忙看一下关于画图组件部署问题
我去看了一下数据库里面没有 img这种东西 怎么办呀content.Replace("<img[^>]*>","");
public static string wipescript(string html)
{
System.Text.RegularExpressions.Regex regex0 = new System.Text.RegularExpressions.Regex(@"<(.[^>]*)>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex1 = new System.Text.RegularExpressions.Regex(@"(\<.[^\<]*\>)", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex2 = new System.Text.RegularExpressions.Regex(@"(\<\/[^\<]*\>)", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex3 = new System.Text.RegularExpressions.Regex(@"<(.[^>]*)>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex4 = new System.Text.RegularExpressions.Regex(@"<iframe[\s\s]+</iframe *>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex5 = new System.Text.RegularExpressions.Regex(@"<frameset[\s\s]+</frameset *>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex6 = new System.Text.RegularExpressions.Regex(@"<(\S*?)[^>]*>.*? </\1> | <.*?/>", System.Text.RegularExpressions.RegexOptions.IgnoreCase); html = regex0.Replace(html, "");
html = regex1.Replace(html, "");
html = regex2.Replace(html, "");
html = regex3.Replace(html, "");
html = regex4.Replace(html, "");
html = regex5.Replace(html, "");
html = regex6.Replace(html, "");
return html;
}
protected string FormatStr(string str)
{
str = System.Text.RegularExpressions.Regex.Replace(str, "<[^>]+>", "");
str = str.Length > 50 ? str.Substring(0, 50) + "..." : str;
return str;
}