An ASP Replacement function img Inside the extra code _ Application Tips

Source: Internet
Author: User
<%
Response.Write (Server.HTMLEncode (fiximg ("screen.width-461) window.open (' qq/ 20082181405371.jpg '); "" Alt= "" "" Border= "" 0 "" src= "" qq/20082181405371.jpg ""/> "))
%>
<%
' Function: Format the IMG code as format.
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, "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 = " "
Sreallydo = Regex.Replace (Sreallydo, "Fiximg = Sreallydo
End Function
%>
<%
' Function: Returns a string in which a specified number of substrings are replaced by another substring.
' Source: http://jorkin.reallydo.com/article.asp?id=406
' Need bint function: http://jorkin.reallydo.com/article.asp?id=395

Function ReplaceAll (Sexpression, Sfind, Sreplacewith, BAll)
If IsNull (sexpression) Then ReplaceAll = "": Exit Function
If (StrComp (BAll, "True", 1) = 0) Or (CBool (Bint (bAll)) = True) Then
Do While INSTR (1, Sexpression, Sfind, 1) > 0
Sexpression = Replace (Sexpression, Sfind, Sreplacewith, 1,-1, 1)
If InStr (1, Sreplacewith, Sfind, 1) >0 Then Exit do
Loop
Else
Do While INSTR (Sexpression, Sfind) > 0
Sexpression = Replace (Sexpression, Sfind, Sreplacewith)
If InStr (Sreplacewith, Sfind) > 0 Then Exit do
Loop
End If
ReplaceAll = Sexpression
End Function
%>
<%
' Function: Only numbers
' Source: http://jorkin.reallydo.com/article.asp?id=395

Function Bint (STR)
str = Trim (str)
If str = "" or IsNull (str) or not isnumeric (str) Then str = "0"
Bint = Round (Str, 0)
End Function
%>

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.