<%
Response.Write(Server.HTMLEncode(FixImg("<img onclick=""if(this.width>screen.width-461) window.open('qq/20082181405371.jpg');"" alt="""" border=""0"" src="/UploadFiles/2021-04-02/">%>
<%
'功能:将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="/UploadFiles/2021-04-02/"> '//正则匹配图片SRC地址
regEx.Pattern = "<img.*?\ssrc=([\""\'])([^\""\']+?)\1.*?>"
sReallyDo = regEx.Replace(sReallyDo, "<img src="/UploadFiles/2021-04-02/"> 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
%>
Response.Write(Server.HTMLEncode(FixImg("<img onclick=""if(this.width>screen.width-461) window.open('qq/20082181405371.jpg');"" alt="""" border=""0"" src="/UploadFiles/2021-04-02/">%>
<%
'功能:将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="/UploadFiles/2021-04-02/"> '//正则匹配图片SRC地址
regEx.Pattern = "<img.*?\ssrc=([\""\'])([^\""\']+?)\1.*?>"
sReallyDo = regEx.Replace(sReallyDo, "<img src="/UploadFiles/2021-04-02/"> 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,替换函数
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
桃源资源网 Design By www.nqtax.com
暂无“一个asp替换函数img里面多余的代码”评论...
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。