手机
当前位置:查字典教程网 >编程开发 >ASP教程 >一个asp替换函数img里面多余的代码
一个asp替换函数img里面多余的代码
摘要:

<%

Response.Write(Server.HTMLEncode(FixImg("<imgonclick=""if(this.width>screen.width-461)window.open('qq/20082181405371.jpg');""alt=""""border=""0""src=""qq/20082181405371.jpg""/>")))

%>

<%

'功能:将IMG代码格式化为<imgsrc="XXX"/>格式.

FunctionFixImg(sString)

DimsReallyDo,regEx,iReallyDo

DimoMatches,cMatch

DimtStartTime,tEndTime

IfIsNull(sString)Then

FixImg=""

ExitFunction

EndIf

sReallyDo=sString

OnErrorResumeNext

sReallyDo=Replace(sReallyDo,vbCr,"")

sReallyDo=Replace(sReallyDo,vbLf,"")

sReallyDo=Replace(sReallyDo,vbTab,"")

sReallyDo=Replace(sReallyDo,"<img",vbCrLf&"<img",1,-1,1)

sReallyDo=Replace(sReallyDo,"/>","/>",1,-1,1)

sReallyDo=ReplaceAll(sReallyDo,"=","=",True)

sReallyDo=ReplaceAll(sReallyDo,">",">",True)

sReallyDo=Replace(sReallyDo,"><",">"&vbCrLf&"<")

sReallyDo=Trim(sReallyDo)

OnErrorGoTo0

SetregEx=NewRegExp

regEx.IgnoreCase=True

regEx.Global=True

'//去除onclick,onload等脚本

regEx.Pattern="s[on].+?=([""|'])(.*?)1"

sReallyDo=regEx.Replace(sReallyDo,"")

'//将SRC不带引号的图片地址加上引号

regEx.Pattern="<img.*?ssrc=([^""'s][^""'s>]*).*?>"

sReallyDo=regEx.Replace(sReallyDo,"<imgsrc=""$1""/>")

'//正则匹配图片SRC地址

regEx.Pattern="<img.*?ssrc=([""'])([^""']+?)1.*?>"

sReallyDo=regEx.Replace(sReallyDo,"<imgsrc=""$2""/>")

FixImg=sReallyDo

EndFunction

%>

<%

'功能:返回字符串,其中指定数目的某子字符串全部被替换为另一个子字符串。

'来源:http://jorkin.reallydo.com/article.asp?id=406

'需要Bint函数:http://jorkin.reallydo.com/article.asp?id=395

FunctionReplaceAll(sExpression,sFind,sReplaceWith,bAll)

IfIsNull(sExpression)ThenReplaceAll="":ExitFunction

If(StrComp(bAll,"True",1)=0)Or(CBool(Bint(bAll))=True)Then

DoWhileInStr(1,sExpression,sFind,1)>0

sExpression=Replace(sExpression,sFind,sReplaceWith,1,-1,1)

IfInStr(1,sReplaceWith,sFind,1)>0ThenExitDo

Loop

Else

DoWhileInStr(sExpression,sFind)>0

sExpression=Replace(sExpression,sFind,sReplaceWith)

IfInStr(sReplaceWith,sFind)>0ThenExitDo

Loop

EndIf

ReplaceAll=sExpression

EndFunction

%>

<%

'功能:只取数字

'来源:http://jorkin.reallydo.com/article.asp?id=395

FunctionBint(Str)

Str=Trim(Str)

IfStr=""OrIsNull(Str)OrNotIsNumeric(Str)ThenStr="0"

Bint=Round(Str,0)

EndFunction

%>

【一个asp替换函数img里面多余的代码】相关文章:

限制一个Ip只能访问一次的asp代码

ASP下实现自动采集程序及入库的代码

ASP编程常用的代码

Asp遍历服务器对象的代码

asp 过滤简单html代码程序

用asp实现的数据库中存取文件的代码

替换数据库内容

asp 查询数据代码

asp完整登陆代码

一段采集程序代码

精品推荐
分类导航