[Import] common ASP functions: getIMG ()

Source: Internet
Author: User

There are still bugs, the latest test page in: http://www.reallydo.com/getimg.asp
Regular analysis page in: http://jorkin.reallydo.com/article.asp? Id = 380
Please leave a message after discovering the BUG. Thank you.

1.31 Amendment
Src = the following space cannot match correctly. corrected.
An error occurred when src = ''is null. corrected.
Detected BUG: Only one space can be retained when the image path has multiple spaces. It is not corrected.
2.18 Amendment
Only one BUG can be retained when there are multiple spaces in the image path. Fixed.

<%
'Function: Get all image addresses and save them 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
'// Defines an empty array
IReallyDo =-1
ReDim aReallyDo (iReallyDo)
If IsNull (sString) Then
GetIMG = ""
Exit Function
End If
'// Format the HTML code
'// Wrap each 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 the onclick, onload, and other scripts
RegEx. pattern = "\ s [on]. +? = ([\ "" | \ ']) (. *?) \ 1"
Sreallydo = RegEx. Replace (sreallydo ,"")
'// Enclose the image address of SRC without quotation marks with quotation marks
RegEx. pattern = "] *). *?> "
Sreallydo = RegEx. Replace (sreallydo, " ")
'// The SRC address of the matching image
RegEx. pattern = " "
Set omatches = RegEx. Execute (sreallydo)
'// Save the image address to an array
For each cmatch in omatches
Ireallydo = ireallydo + 1
Redim preserve areallydo (ireallydo)
Areallydo (ireallydo) = RegEx. Replace (cmatch. value, "$2 ")
Next
Getimg = areallydo
End Function
%>

Source: http://Jorkin.Reallydo.Com/default.asp? Id = 448

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.