- <%
- Response.Write(Server.HTMLEncode(FixImg("<img onclick=""if(this.width>screen.width-461) window.open('qq/20082181405371.jpg');"" alt="""" border=""0"" src=""qq/20082181405371.jpg"" />")))
- %>
- <%
- '功能:将IMG代码格式化为<img src="XXX" />格式.
- Function FixImg(sString)
- Dim sReallyDo, regEx, iReallyDo
- Dim oMatches, cMatch
- Dim tStartTime, tEndTime
- If IsNull(sString) Then
- FixImg = ""
- Exit Function
- End If
- sReallyDo = sString
- On Error Resume Next
- 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)
- On Error GoTo 0
- Set regEx = New RegExp
- 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, "<img src=""$1"" />")
- '//正则匹配图片SRC地址
- regEx.Pattern = "<img.*?\ssrc=([\""\'])([^\""\']+?)\1.*?>"
- sReallyDo = regEx.Replace(sReallyDo, "<img src=""$2"" />")
- FixImg = sReallyDo
- End Function
- %>
- <%
- '功能:返回字符串,其中指定数目的某子字符串 全部 被替换为另一个子字符串。
- '来源:http://jorkin.reallydo.com/article.asp?id=406
- '需要Bint函数:http://jorkin.reallydo.com/article.asp?id=395
- Function ReplaceAll(sExpression, sFind, sReplaceWith, bAll)
- If IsNull(sExpression) Then ReplaceAll = "" : Exit Function
- If (StrComp(bAll, "True", 1) = 0) Or (CBool(Bint(bAll)) = True) Then
- Do While InStr( 1, sExpression, sFind, 1) > 0
- sExpression = Replace(sExpression, sFind, sReplaceWith, 1, -1, 1)
- If InStr( 1, sReplaceWith , sFind , 1) >0 Then Exit Do
- Loop
- Else
- Do While InStr(sExpression, sFind) > 0
- sExpression = Replace(sExpression, sFind, sReplaceWith)
- If InStr(sReplaceWith, sFind ) > 0 Then Exit Do
- Loop
- End If
- ReplaceAll = sExpression
- End Function
- %>
- <%
- '功能:只取数字
- '来源:http://jorkin.reallydo.com/article.asp?id=395
- Function Bint(Str)
- Str = Trim(Str)
- If Str = "" Or IsNull(Str) Or Not IsNumeric(Str) Then Str = "0"
- Bint = Round(Str, 0)
- End Function
- %>
一个asp替换函数img里面多余的代码
2019-09-29 11:02asp代码网 ASP教程
一个asp替换函数img里面多余的代码
延伸 · 阅读
- 2021-10-20关于ASP网页无法打开的解决方案
- 2021-10-14让apache也支持asp环境的方法
- 2021-08-15asp取整数mod 有小数的就自动加1
- 2021-08-15asp与php中定时生成页面的思路与代码
- 2021-05-09IIS 7.5 asp Session超时时间设置方法
- 2021-05-06java正则替换img标签中src值的方法
精彩推荐
- ASP教程
ASP GetRef 函数指针试探
近日在学习C++,看到函数指针,由于之前一直搞ASP,所以想ASP里面是否也有这个函数指针的东西,百度了一下,没有太多关于此方面的介绍,于是翻了翻...
- ASP教程
ASP常用函数:HTMLDecode
ASP常用函数:HTMLDecode ...
- ASP教程
ASP实现文件上传的方法
在基于浏览器/服务器的应用环境中,在浏览器中上传各种类型的文件一直是困扰用户文件管理应用的难题之一。常用的实现方法是利用在RFC1867中引入的一...
- ASP教程
asp中一段防SQL注入的通用脚本
asp中一段防SQL注入的通用脚本...
- ASP教程
asp删除mssql数据库中没有记录的图片代码
asp删除没有记录的图片需要文件夹(存放图片的文件夹)中的每个图片和数据库中的所有记录进行比较...
- ASP教程
asp读取远程文件并保存到本地代码
asp读取远程文件并保存到本地代码 ...
- ASP教程
字符批量替换程序asp服务器版
字符批量替换程序asp服务器版,安装方法:直接把replace.asp文件放在任意的支持asp+FSO的环境中 ...
- ASP教程
ASP 判断是否有中文的代码
其实我上一篇写的js判断中文才是最好的方法,这个是asp的一种,只要是双字节都是当作中文判断...