1. 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
%>
2. ASP如何過濾數組內重復內容
dim a(4)
a(0)=1
a(1)=1
a(2)=2
a(3)=2
a(4)=3
for n=0 to ubound(a)-1
for s=1 to ubound(a)
if a(s)=a(n) then
a(n)=""
end if
next
next
a_new=filter(a,"")『把a數組裡面是空值的全部刪掉,然後重新組合成一個a_new數組。
for n=0 to ubound(a_new)』列印出a_new數組。
response.write a_new(n)&"<br>"
next
說明:a_new是新生成的數組,去掉了a數組裡面被清空的那些,重新生成了一個開頭角標是0的a_new數組。
3. 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 我自己做的,希望對你有幫助