Page | array | image address 1.31 correction
There are spaces behind the src= that do not match correctly. Modified.
Error src= ' is empty. Modified.
Bug found: A picture path can have more than one space. Not fixed.
2.18 Amendment
A picture path can have more than one space in it. has been fixed.
Here's the code:
<%
' Function: Get all picture addresses, save to an array.
' Source: http://jorkin.reallydo.com/article.asp?id=448
' Need ReplaceAll function: http://jorkin.reallydo.com/article.asp?id=406
Function getimg (sstring)
Dim Sreallydo, RegEx, Ireallydo
Dim Omatches, Cmatch
'//define an empty array
Ireallydo =-1
ReDim Areallydo (Ireallydo)
If IsNull (sstring) Then
Getimg = ""
Exit Function
End If
'//Format HTML code
'//Sreallydo = sstring
On Error Resume Next
Sreallydo = Replace (Sreallydo, vbcr, "")
Sreallydo = Replace (Sreallydo, vblf, "")
Sreallydo = Replace (Sreallydo, VbTab, "")
Sreallydo = Replace (Sreallydo, "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
'//Remove scripts such as Onclick,onload
Regex.pattern = "\s[on].+?= ([\" "|\ '])" (. *?) \1 "
Sreallydo = Regex.Replace (Sreallydo, "")
'//Add quotation marks to the picture address of SRC without quotes
Regex.pattern = "]*) .*?>"
Sreallydo = Regex.Replace (Sreallydo, "'//Regular matching picture src address
Regex.pattern = " "
Set omatches = Regex.execute (Sreallydo)
'//Save picture address in array
For each cmatch in omatches
Ireallydo = Ireallydo + 1
ReDim Preserve Areallydo (Ireallydo)
Areallydo (Ireallydo) = Regex.Replace (Cmatch.value, "$")
Next
Getimg = Areallydo
End Function
%> |