❶ 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