Ⅰ ASP字符串查询是否含有指定字符
<%
a="虽然复他是一只骄傲制的孔雀,算不上是王子殿下"
b="孔雀,王子,骄傲"
c=instr(b,a)
response.Write(c)
%>如果instr里面存在相关字符的话,返回所在的位置,如果,不存在的话,返回0
不会返回负数
Ⅱ 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中,如何去掉指定字符或者字符串后面的所有字符
<%
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过滤字符串中非英文和数字的所有字符
=========================================
ASP过滤字符串,保留英文字母(A-Z 和 a-z)吗?
=========================================
<%
ORI = "我有1只Cat,2只Dogs,3只Rabbits,4只Tigers和5只Pigs!我的家像Zoo!"
for i = 1 to len(ORI)
j = mid(ORI,i,1)
if (j>=CHR(65) and j<=CHR(90)) or (j>=CHR(97) and j<=CHR(122)) then
TXT = TXT & j
else
DUM = DUM & j
end if
next
response.write TXT & " " & DUM
%>
ORI = 原字符串(我回有1只Cat,2只Dogs,3只Rabbits,4只Tigers和5只Pigs!我的家像Zoo!)
TXT = 过滤后的英文字母(CatDogsRabbitsTigersPigsZoo)
DUM = 过滤后的非英文字母(我有1只,2只,3只,4只和5只!答我的家像!)
Ⅳ 怎样过滤掉字符串的中文 asp中
你用 ASC 码 判断 看行不 行
Ⅵ 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上的字符串处理
<%
yctype=request("type")
if instr(yctype,"<")>0 or instr(yctype,">")>0 then yctype=""
%>
Ⅸ ASP字符过滤。
username=trim(request.form("username"))
'定义一个数组
badCode="<,%,@,upload"
'分割数据
badCode=split(badCode,",")
'从第一个循环到最后一个
for i = 0 to ubound(badCode)
username=replace(username,badCode(i),"") '把这专些字符替换属为空
next
Ⅹ ASP 将当前时间转换为字符串
asp没有现成的函数,只能自己自定义一个函数。
<%
Function FormatDTime(psDateTime)
Dim sDateTime
sDateTime =Year(psDateTime)
If Cint(Month(psDateTime)) <10 Then sDateTime =sDateTime &"0"
sDateTime =sDateTime & Month(psDateTime)
If Cint(Day(psDateTime)) <10 Then sDateTime =sDateTime &"0"
sDateTime =sDateTime & Day(psDateTime)
If Cint(Hour(psDateTime)) <10 Then sDateTime =sDateTime &"0"
sDateTime =sDateTime & Hour(psDateTime)
If Cint(Minute(psDateTime)) <10 Then sDateTime =sDateTime &"0"
sDateTime =sDateTime & Minute(psDateTime)
If Cint(Second(psDateTime)) <10 Then sDateTime =sDateTime &"0"
sDateTime =sDateTime & Second(psDateTime)
FormatDTime =sDateTime
End Function
%>
调用:
<% =FormatDTime(now) %>