当用户发表言论的时候,我们把脏字替换成* ,要如何做?各位详细讲讲,最好给我个例子 邮箱:[email protected]
解决方案 »
- 在网页中根据需要动态显示一部分内容的问题
- 怎么在服务器端弹出网页确认取消对话框并获取选择?
- 头部控件中有搜索功能和登录功能,要怎么样才能在搜索文本中点击回车才触发搜索按钮?
- 问高人:解释下ajax的原理(期待最容易懂的表达方式)
- 实时获取数据库记录
- asp.net和mysql的亂碼問題,見過這個問題幫個忙
- ASP。NET实现CSDN这样导航栏的隐藏和显示?如何操作??
- 计算字符表达式的值并返回结果,eval()
- 一个跨页面提交FORM的问题
- dropdownlist 在altas等無刷新的panel中,當提交時。為什么總會閃動。有辦法解決嗎?
- 急啊~~~~~~~
- |zyciis| 如何得到当前执行的方法的名称,谢谢
try {
resultString = Regex.Replace("frgr脏字1feagreg脏字2grsgr", @"脏字1|脏字2|脏字3", @"xxxxx");
} catch (ArgumentException ex) {
// Syntax error in the regular expression
}
//判断给定字符串内是否含有敏感词,true代表有,false代表没有
Page.Request.ContentEncoding = Encoding.GetEncoding("utf-8");
Page.Response.ContentEncoding = Encoding.GetEncoding("utf-8");
Response.ContentType = "application/json";
string strValue=Request["text"];//这是你的内容
if (strValue == null) strValue = "";
strValue=Microsoft.JScript.GlobalObject.unescape(strValue);
strValue = ;//过滤HTML(把你认为的非法字读出)
bool bResult=;//判断是否该替换
Response.Write("{result:'" + bResult.ToString().ToLower() + "'}");
}
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;
}