❶ asp 字符串过滤
我已写成一个函数,如下:
Function KeyWordAddLink(Byval strText,Byval strReplace)
Dim re,s,i,strKey,strSubKey
set re = New RegExp
re.IgnoreCase = True
re.Global = True
s = strText
strKey = Split(strReplace,"||")
For i = 0 To UBound(strKey)
If strKey(i) <> "" Then
strSubKey = Split(strKey(i),">>")
If strSubKey(0) <> "" Then
re.Pattern = "(^|[^\/\\\w\=])(" & strSubKey(0) & ")"
s=re.Replace(s, "$1<a target=""_blank"" href=""" & strSubKey(1) & """ class=""KeyLink""><font color=""red""><b>$2</b></font></a>")
End If
End If
Next
KeyWordAddLink=s
set re = nothing
End Function
参数strText :被替换的文本
参数strReplace :用来替换的文本
示例:
dim word,replaceStr
word="网络是搜索引擎"
replaceStr="网络>>http://www..com||搜索>>http://www.g.cn"
word = KeyWordAddLink(word,replaceStr)
Response.Write word
结果输出:
<a target="_blank" href="http://www..com" class="KeyLink"><font color="red"><b>网络</b></font></a>是一个<a target="_blank" href="http://www.g.cn" class="KeyLink"><font color="red"><b>搜索</b></font></a>引擎
❷ ASP过滤函数
正则可以帮你解决
给你一个过回滤HTML函数答
Function RemoveHTML(strHTML)
Dim objRegExp, Match, Matches
Set objRegExp = New Regexp
objRegExp.IgnoreCase = True
objRegExp.Global = True
objRegExp.Pattern = "<.+?>"
Set Matches = objRegExp.Execute(strHTML)
For Each Match in Matches
strHtml=Replace(strHTML,Match.Value,"")
Next
RemoveHTML=strHTML
Set objRegExp = Nothing
End Function
❸ ASP过滤脏字
Const yaoguolv="脏字1|脏字2" '需要过滤得字符以“|”隔开,最后结束的字符必须是|
yaoguolv1=Split(yaoguolv,"|")
word1=LCase(request.form("name"))
word2=LCase(request.form("lx"))
word3=LCase(request.form("title"))
For i=LBound(yaoguolv1) To UBound(yaoguolv1)
If Instr(word1,yaoguolv1(i))=0 Then
else
Response.Write "<script>alert('对不起,请不要输入脏字!');history.back();</script>"
response.end
End If
If Instr(word2,yaoguolv1(i))=0 Then
else
Response.Write "<script>alert('对不起,请不要输入脏字!');history.back();</script>"
response.end
End If
If Instr(word3,yaoguolv1(i))=0 Then
else
Response.Write "<script>alert('对不起,请不要输入脏字!');history.back();</script>"
response.end
End If
Next
❹ asp中如何过滤掉特殊字符
user=replace(trim(request.form("uName")),"'","''")
password=replace(trim(request.form("Password")),"'","''")
if instr(user,"%") or instr(user,"#") or instr(user,"?") or instr(user,"|") or instr(user,"'") then
response.write "<script language=javascript>alert('您的姓名含有非法字符!');this.location.href='login.asp';</script>"
response.end
end if
if instr(password,"%") or instr(password,"#") or instr(password,"?") or instr(password,"|") then
response.write "<script language=javascript>alert('您的密码含有非法字符!');this.location.href='login.asp';</script>"
response.end
end if 我自己做的,希望对你有帮助
❺ asp过滤所有的html代码函数
应该是可以过掉所有的标签的.大小写已经忽略,全局已经打开,多行也打开着,看了一下你的匹配专式也是正确的属啊.你过不掉的可能是因为中间有空间,而[^>]表示的是不包含>的所有字符.怎么会过滤不掉呢?
"<[\/]?\w+(\s+\w+\=[\"]?\w+[\"]?)*[\/]?>"
这样试试如何
❻ ASP脏话过滤
这写的很详细了
content=request("content")
content=replace(content,"脏话","**")
最好利用数据库,把要过滤的脏话都写入库
然后写个函专数,其中属用FOR循环上面的语句,“脏话”二字替换为从你数据库中读取的内容!!
❼ 求asp字符串过滤防止sql注入等安全选项的过滤代码
这个函数可以解决
Function SafeRequest(ParaName,ParaType)
'--- 传入参数 ---
'ParaName:参数名称-字符型
'ParaType:参数类型-数字型(1表示以上参数是数专字,0表示以上参数为属字符)
Dim ParaValue
ParaValue=Request(ParaName)
If ParaType=1 then
If not isNumeric(ParaValue) then
Response.write "参数" & ParaName & "必须为数字型!"
Response.end
End if
Else
ParaValue=replace(ParaValue,"'","''")
End if
SafeRequest=ParaValue
End function
❽ asp怎样过滤重复的词组
试试这个函数
<%
Dims
s="中国,美国,法国,意大利,美国,澳大利亚,中国,澳大利亚,泰国"
response.writedelR(s)
FunctiondelR(ByValstr)
Dimarr,b(),i,j,k,sf
arr=Split(str,",")
ReDimb(k):b(k)=arr(0)
Fori=1ToUBound(arr)
sf=False
Forj=0ToUBound(b)
Ifb(j)=arr(i)Then
sf=True
ExitFor
EndIf
Next
Ifsf=FalseThen
k=k+1
ReDimPreserveb(k)
b(k)=arr(i)
EndIf
Next
delR=Join(b,",")
EndFunction
%>
❾ ASP字符过滤。
username=trim(request.form("username"))
'定义一个数组
badCode="<,%,@,upload"
'分割数据
badCode=split(badCode,",")
'从第一个循环到最后一个
for i = 0 to ubound(badCode)
username=replace(username,badCode(i),"") '把这专些字符替换属为空
next
❿ ASP过滤掉之间的内容
REPLACE(
REPLACE("[img]UPic/20116/20116178203198148.gif[/img]","[img]",""),
"[/img]","")