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=https://www.jb51.net/article/([^””\’\s][^””\’\s>]*).*?>”
sReallyDo=regEx.Replace(sReallyDo, “<img src=”https://www.jb51.net/article/”$1″” />”)
‘//正则匹配图片SRC地址
regEx.Pattern=”<img.*?\ssrc=https://www.jb51.net/article/([“”\’])([^””\’]+?)\1.*?>”
sReallyDo=regEx.Replace(sReallyDo, “<img src=”https://www.jb51.net/article/”$2″” />”)
FixImg=sReallyDo
End Function
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=https://www.jb51.net/article/([^””\’\s][^””\’\s>]*).*?>”
sReallyDo=regEx.Replace(sReallyDo, “<img src=”https://www.jb51.net/article/”$1″” />”)
‘//正则匹配图片SRC地址
regEx.Pattern=”<img.*?\ssrc=https://www.jb51.net/article/([“”\’])([^””\’]+?)\1.*?>”
sReallyDo=regEx.Replace(sReallyDo, “<img src=”https://www.jb51.net/article/”$2″” />”)
FixImg=sReallyDo
End Function
© 版权声明
文章版权归作者所有,未经允许请勿转载。