ASP uses regular expressions to batch separate the images in the editing box to obtain the image path

Source: Internet
Author: User

This function can read all the image paths in the HTML code, so that you can save the image paths obtained in batches to the database, add watermarks to images in batches, or scale down images in batches, it is very convenient to operate as needed.
If the path starts with http: //, you can use the remote file download function to download the file. In this way, remote images or files are downloaded in batches.
Function oflink_lcasetag (imgstrng)
'Extraordinary design original 361du.net
'Convert the tags in the HTML code of the content to lowercase.
Dim RegEx, match, matches 'to create a variable.
Set RegEx = new Regexp 'to create a regular expression.
RegEx. pattern = "<. +? \> "'Setting mode.
RegEx. ignorecase = true' specifies whether the characters are case sensitive.
RegEx. Global = true' to set global availability.
Set matches = RegEx. Execute (imgstrng) 'to execute the search.
Imgstrng = imgstrng
For each match in matches 'traverses the matching set.
Imgstrng = Replace (imgstrng, match. Value, lcase (match. Value ))
Next
Oflink_lcasetag = imgstrng
End Function
Function ofink_getsrc (strng)
'Extraordinary design original 361du.net
'Batch retrieve image paths
Strng = oflink_lcasetag (strng)
Dim RegEx, match, matches, values, if_add' create a variable.
Set RegEx = new Regexp 'to create a regular expression.
RegEx. pattern = "src \ =. +? \. (GIF | JPG | JPEG | jpe | PNG )"
RegEx. ignorecase = true' specifies whether the characters are case sensitive.
RegEx. Global = true' to set global availability.
Set matches = RegEx. Execute (strng) 'to execute the search.
If_add = 0
For each match in matches 'traverses the matching set.
Values = Values & Match. Value & "|"
If_add = 1
Next
Values = Replace (values, "src = ""","")
Values = Replace (values, "src = '","")
Values = Replace (values, "src = ","")
If if_add = 1 then values = left (values, Len (values)-1)
Ofink_getsrc = values
End Function
How to use this function: imglist = ofink_getsrc (content)
Content can be the content of multiple images in the editing box.
The imglist results are separated by "|", for example, 1.jpg | 2.jpg | 3.jpg.
After this result is obtained, you can use the split function to obtain a single image. You just need to perform any operations on the image.

Related Article

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.