Ⅰ 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) %>