ASP picture is replaced, before the replacement check the picture is the local address method _ Regular expression

Source: Internet
Author: User
Direct replacement with regular, but no judgment function
Function formatimg (content)
Dim re
Set re=new REGEXP
Re. IgnoreCase =true
Re. Global=true
Re. pattern= "(script)"
Content=re. Replace (Content, "script")
Re. Pattern= "]*src (=|) (. [^>]*) > "
Content=re.replace (Content, "Set re = Nothing
formatimg = Content
End Function
This code replaces the picture in the content with the in this form,
I now need to extract the first 7 characters of $ to determine if the need to be replaced, if the first 7 = a specific character, do not replace, but get $7 cannot. What can we do to recruit Satan?

The main reference is the following code, you can see
' Connect
Re. Pattern = "\[url= (. [ ^\]]*)\](. [^\[]*) \[\/url] "
Set Strmatchs=re. Execute (strcontent)
For each strmatch in Strmatchs
Tmpstr1=checkurl (strmatch.submatches (0))
Tmpstr2=strmatch.submatches (1)
Strcontent=replace (Strcontent,strmatch.value, "<a target=" "_blank" "href=" "" &tmpStr1& "" > "& tmpstr2& "</a>", 1,-1,0)
Next
Here is the documentation for the regular matchs.
Http://www.jb51.net/article/15362.htm

Here's a cloud-dwelling community that tests the code, and you can make a function
<%
content2= " The middle of some content '
Dim re
Set re=new REGEXP
Re. IgnoreCase =true
Re. Global=true
Re. Pattern= "]*src (=|) (. [^>]*) [/]?> "
Set Matches=re.execute (Content2)
For each strmatch in matches
Tmpstr1= (Strmatch.submatches (1))
Tmpurl=replace (replace (TMPSTR1, "'", ""), "" "", "" "
Response.Write Left (tmpurl,20)
If left (tmpurl,19) = "Http://www.jb51.net" Then
Picurl=tmpurl
Else
Picurl= "Http://img.jb51.net/showpic.asp?url=" &tmpurl
End If
Content=replace (Content2,strmatch.value, "Next
Response.Write Content
Set re = Nothing

%>
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.