急急!!如何过滤脏话??,听说是用可以记事本写,请问该怎么写。或者其他什么好办法??
解决方案 »
- 大家帮忙 着急!!!rdlc报表 的文本框 怎么获取数据库的数据啊?
- foreach中可以添加break吗?
- 关于测试软件的一些问题,请大家说下
- csdn骗分
- IIS默认站点(停止),启动也不好使.怎么解决啊?
- 我用asp.net创建web站点成功,但却无法访问任何文件 在线等待
- 菜鸟问题,帮个忙,关于Session的
- 关于oracle存储过程参数问题,求高手指点
- 求救,一个奇怪的问题,很着急~~
- Page.RegisterStartupScript("","<script>if(confirm('"+ Session["Moban"] +"您确认吗?')==true){alert('你选择了确认')}</script>");
- 静态页转换成aspx页后,js效果无法显示问题
- 急急!!如何过滤脏话??
void Application_BeginRequest(object sender, EventArgs e)
{
for (int i=0; i < Request.Form.Count;i++)
{
if (Request.Form[i].ToString() == "__VIEWSTATE") continue;
if (IsM(Request.Form[i].ToString()))
{
Response.Write("您提交的内容中含有非法字符.");
Response.End();
} }
}
protected bool IsM(string InText)
{
string word = @"";
if (InText == null)
return false;
if (Regex.IsMatch(InText,word))
return true;
return false;
}
http://topic.csdn.net/u/20081115/21/545fb4ee-8013-4c8f-87ac-9198eece8f2b.html?seed=443082488
{
//这里读取数据
//string name1 = "web_config";
//string sql = "select webnotext from web_config";
//DataSet ds = mssql.GreatDs(sql, name1);
////这里就是过滤了
//string badwords = ds.Tables[0].Rows[0]["webnotext"].ToString();
//上边从数据库中读取要过滤的字符
string badwords = "晕|倒";
string[] tempstr = badwords.Split('|');
string finalstr = msg;
for (int i = 0; i < tempstr.Length; i++)
{
finalstr = finalstr.Replace(tempstr[i], new String('*', tempstr[i].Length));
}
return finalstr;
}