private static string _wf;
//过滤敏感词
public static string WORD_FILTER
{
get
{
if (_wf == null || _wf.Trim() == "")
{
TextReader tr = System.IO.File.OpenText(System.Configuration.ConfigurationManager.AppSettings["WordFilter"]);
string str = tr.ReadToEnd();
tr.Close();
_wf = str.Replace("/r/n", "|");
}
return _wf;
}
set { _wf = value; }
}
public static string FormatContent(string content)
{
if (WORD_FILTER != null && WORD_FILTER.Trim() != "")
{
Regex r = new Regex(Config.WORD_FILTER, RegexOptions.IgnoreCase);
content = HttpUtility.HtmlEncode(r.Replace(content, "*"));
return content;
}
else
{
throw new Exception();
}
}
过滤敏感词
最新推荐文章于 2022-10-24 14:00:22 发布