❶ 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]","")