function code Analysis of HTML removal with ASP example illustration _ Application Tips

Source: Internet
Author: User

The following code does not replace the middle of ld<sad, so the content is still normal

Copy Code code as follows:

<%
function nohtml (str)
Dim re
Set re=new REGEXP
Re. IgnoreCase =true
Re. Global=true
Re. Pattern= "(\<.[ ^\<]*\>) "
Str=re.replace (str, "")
Re. Pattern= "(\<\/[^\<]*\>)"
Str=re.replace (str, "")
Str=replace (str, "", "")
Str=replace (str, "", "")
Nohtml=str
Set re=nothing
End Function
Str= "<TITLE>SADJKSJDL Cloud Communities welcome you sajdljsald<sadsadsad<br>" ' Here is the test
Response.Write nohtml (str)
%>

The results are:
Copy Code code as follows:

Welcome to SADJKSJDL Cloud-dwelling community Sajdljsald<sadsadsad

But the following code is not asked, directly to see < forget the following unlimited matching
Copy Code code as follows:

<%
Function drophtml (Byval strhtml)
Dim objRegExp, Match, Matches
Set objRegExp = New Regexp
Objregexp.ignorecase = True
Objregexp.global = True
' Take the closed <>
Objregexp.pattern = "<.+?>"
' to match
Set matches = Objregexp.execute (strhtml)
' Iterate through the matching set and replace the matching item
For the Match in matches
Strhtml=replace (Strhtml,match.value, "")
Next
Drophtml=strhtml
Set objRegExp = Nothing
End Function
Str= "<TITLE>SADJKSJDL Cloud Communities welcome you sajdljsald<sadsadsad<br>" ' Here is the test
Response.Write drophtml (str)
%>

The results are:
Copy Code code as follows:

Welcome to SADJKSJDL Cloud-dwelling community Sajdljsald

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.