❶ asp中如何去掉一段字元串中的標簽
使用正則表達式替換
html = RemoveTags(html)
public function RemoveTags(byval str)
dim re
set re = new RegExp
re.IgnoreCase = true
re.Global = true
re.Pattern = "(\<\/?[^\<]*\>)"
RemoveTags = re.Replace(str, "")
set re = nothing
end function
❷ 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中過濾字元串的語法是什麼呀,怎麼用
你要過濾什麼?
過濾的話一般是寫一個替換函數,把你不想要的內容替換掉。比如會留下漏洞的
特殊字元
什麼的。
❹ asp 去掉字元串前
string str = "vbcrlf測試顯示";
string sk = str.Substring(6, str.Length - 6);
顯示去掉開頭6位的剩餘字元(即去掉vbcrlf)
❺ ASP字元過濾。
username=trim(request.form("username"))
'定義一個數組
badCode="<,%,@,upload"
'分割數據
badCode=split(badCode,",")
'從第一個循環到最後一個
for i = 0 to ubound(badCode)
username=replace(username,badCode(i),"") '把這專些字元替換屬為空
next
❻ 在asp中怎麼過濾用戶輸入的非法字元
<%
dim texts
texts=request("表單明")
dim kill '要過濾的字元
kill="牆,垃,圍毆" '比喻
dim rsss
rsss=split(kill,",")
dim i,xxxx,yyyy
for i=0 to ubound(rsss)
xxxx=len(rsss(i))
dim j
for j=1 to xxxx
yyyy=yyyy&"*"
next
dim zzzz '過濾後的字元串
if i=0 then zzzz=texts
'如果你想把過濾字版符換成*
zzzz=replace(zzzz,rsss(i),yyyy)
'如果你想把過濾字元直接去掉
zzzz=replace(zzzz,rsss(i),"")
next
'zzzz就是過權濾後的字元了
%>
❼ ASP過濾字元串
這兩個函數一個去掉標記和一個不去掉標記:
Function outHTML(str)
Dim sTemp
sTemp = str
outHTML = ""
If IsNull(sTemp) = True Then
Exit Function
End If
sTemp = Replace(sTemp, "&", "&")
sTemp = Replace(sTemp, "<", "<")
sTemp = Replace(sTemp, ">", ">")
sTemp = Replace(sTemp, Chr(34), """)
sTemp = Replace(sTemp, Chr(10), "<br>")
outHTML = sTemp
End Function
Function inHTML(str)
Dim sTemp
sTemp = str
inHTML = ""
If IsNull(sTemp) = True Then
Exit Function
End If
sTemp = Replace(sTemp, "&", "&")
sTemp = Replace(sTemp, "<", "<")
sTemp = Replace(sTemp, ">", ">")
sTemp = Replace(sTemp, Chr(34), """)
inHTML = sTemp
End Function
❽ 求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中,如何去掉指定字元或者字元串後面的所有字元
<%
function sub_str(byval str, byval pstr) ' str 為要截取的字元串,pstr 限定的字元
pos = instr(str, pstr)
if pos > 0 then str = left(str, pos + len(pstr) - 1)
sub_str = str
end function
str = "upfile/Smallpic/201141314212195588.jpg,%20"
response.Write sub_str(str, ".jpg")
%>
❿ asp 過濾字元串中的某些字元
循環讀取每一行放在數組裡面
s="[00:02.00]歌曲:月半小夜曲"
s=left(s,5)&right(s,len(s)-8)
response.write s