❶ asp 過濾字元 調用
Function ReqNum( StrName )
ReqNum = Request( StrName )
if Not isNumeric( ReqNum ) then
Response.Write "參數必須為數字型!"
Response.End
End if
End Function
Function ReqStr(ReqS)
dim StrName
StrName=request(ReqS)
StrName=replace(StrName,"'","")
StrName=replace(StrName,"%20","")
StrName=replace(StrName,"and","")
StrName=replace(StrName,"or","")
StrName=replace(StrName," ","")
StrName=replace(StrName,"select","")
StrName=replace(StrName,"update","")
StrName=replace(StrName,"delete","")
ReqStr=StrName
End Function
int和string類型的非法字元過濾,可以寫在conn.asp里,調用資料庫的時候,string格式用reqstr("")調用, int格式用regnum("")調用,不知道你問的是不是這個
❷ 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 過濾某字元串中間值
可以參考一下
<%
function replaceByReg(str1,patrn,str)
dim tempReg
set tempReg=new RegExp
tempReg.IgnoreCase=true
tempReg.Global=true
tempReg.pattern=patrn
str1=tempReg.replace(str1,str)
set tempReg=nothing
replaceByReg = str1
end function
str1="【案例十八】學生成專績好壞與未來的屬關系"
patrn="【[\s\S]+?】"
str=""
Response.Write replaceByReg(str1,patrn,str)
%>
❹ ASP如何實現過濾字元(替換字元)
a="hello,who are <br> your ?"
a=Replace(a,"<br>","") 答案補充 a="hello,who are <br> your ?"
a=Replace(a,"<br>","")
a=Replace(a,"your","you") 答案補充 說明一下吧:
Replace是替換函數,格式如下:這個是先定義a這個變數,已經是有內容的了,第二句是把這句話的<br>給過濾掉<Br>,到第三句的時候,a中的<br>已經過濾掉了,再過濾掉your改成you
例子: 答案補充 變數名=Replace(變數名,"過濾的內容","要替換的內容")
❺ 在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中如何過濾指字文字前或指定文字後所有內容呢
可以用正則進行替換,例如以下代碼可以替換a及以後的內所有容字元
<%
str="1234agds34.32"
Dim regEx
Set regEx=new RegExp
regEx.pattern="a.*"
regEx.IgnoreCase =false
regEx.Global=True
str=regEx.Replace(str,"00000")
Response.Write "aaa="&str
%>
❼ 利用ASP 去掉中文字,只留下數字。求幫助
functiongetdg(ms)
dimi,t,s,ss
i=0
dimaa()
fort=1tolen(mstr)
s=mid(mstr,t,1)
ifasc(s)>=48andasc(s)<=57then
ss=ss&s
else
ifss<>""then
redimpreserveaa(i)
aa(i)=ss
i=i+1
ss=""
endif
endif
next
getdg=aa
endfunction
mstr="正品實拍新款女裝修身加厚雙排扣大毛領可拆中長款羽絨棉衣棉服6029新款正品韓版女裝大翻領皮袖毛呢外套1107出貨正品冬季新款韓版通勤高領純色麻花修身淑女毛衣連衣裙5087#-"
dimaa
aa=getdg(mstr)
fort=0toubound(aa)
response.writeaa(t)&","
next
❽ asp 過濾中文字元
可以用正則表達式
就按照163郵箱的格式
·由字母a~z(不區分大小寫)、數字0~9、點、減號或下劃線組成
·只能以數字或字母開頭和結尾,例如:beijing.2008
·用戶名長度為4~18個字元
正則表達式這樣寫:
^[a-zA-Z0-9][\w-\.\d]{3,17}\@[a-zA-Z0-9]+\.[a-zA-Z]{2,4}
❾ 高手進:asp怎麼把文本過濾漢字,字母後只留下數字
<%
function getNum(str)
dim re
set re=new RegExp
re.pattern="\D"
re.global=true
getNum = re.replace(str, "")
end function
%>
<%
a="http://aiyaha.cn/bbs/txt.asp?d=173158.net,http://aiyaha.cn/bbs/txt.asp?d=126.com網址9"
response.write getNum(a)
%>
運行結果:1731581269