ASP Learning: The function that the thief wants to use

Source: Internet
Author: User
Tags html tags
function to think of their own blog or empty on the dot content


by the way how to add other people's articles to their own blog




The
function is used to remove HTML tags from text, and you can control which tags are deleted.


to control the list of deleted labels, you can do this by adding/removing tags to the TagList constant. For example, to retain all <B> labels, remove B from the TagList. The current list contains all the HTML tags and LAYER tags in MSDN. Each label should be used ";" Enclosed.


start and end tags will be deleted, such as "<A...>" and </A...>


if the label is in both the TagList and Blocktaglist constants, all content between the start and end tags will be deleted


tags that do not have an end tag are not treated as HTML tags and their contents are not deleted


Block Label If there is no end tag, everything from the beginning of the label to the end of the text will be deleted


if the character followed by "<!--" is not a space, the annotation label will not be deleted


Use this function is simple:


Strplaintext = removehtml (strtextwithhtml)

The
function reads as follows:





Function removehtml (strText)


Dim taglist


taglist = ";! --;! DOCTYPE; A Acronym; address; APPLET; area; B BASE; Basefont; "&_


"BGSOUND; Big; BLOCKQUOTE; BODY;BR; BUTTON; CAPTION; CENTER; CITE; CODE; "&_


"COL; Colgroup; COMMENT;DD;DEL;DFN;DIR;DIV;DL;DT; EM; EMBED; fieldset; "&_


"FONT; FORM; FRAME; FRAMESET; Head; H1; H2; H3; H4; H5; H6;HR; html;i;iframe;img; "&_


"INPUT;INS;ISINDEX; KBD; LABEL; LAYER; Lagend; LI; LINK; LISTING; MAP; MARQUEE; "&_


"menu; META; nobr; NOFRAMES; Noscript;object;ol;option; P PARAM; plaintext; "&_


"PRE; Q; S Samp; SCRIPT; SELECT; SMALL; SPAN; STRIKE; Strong; STYLE; SUB; SUP; "&_


"TABLE; tbody; TD; TEXTAREA; tfoot;th; THEAD; Title;tr;tt; U UL; VAR; WBR; XMP; "





Const blocktaglist = "; APPLET; EMBED; FRAMESET; Head; NOFRAMES; Noscript;object; SCRIPT; STYLE; "


   


Dim nPos1


Dim NPos2


Dim NPos3


Dim strresult


Dim Strtagname


Dim bremove


Dim Bsearchforblock


   


nPos1 = InStr (StrText, "<")


do While nPos1 > 0


NPos2 = InStr (nPos1 + 1, strText, ">")


If nPos2 > 0 Then


strtagname = Mid (StrText, NPOS1 + 1, npos2-npos1-1)


strtagname = replace (replace (Strtagname, vbcr, ""), vblf, "")





nPos3 = InStr (Strtagname, "")


If nPos3 > 0 Then


Strtagname = Left (Strtagname, npos3-1)


End If


            


If Left (strtagname, 1) = "/" Then


strtagname = Mid (Strtagname, 2)


Bsearchforblock = False


Else


Bsearchforblock = True


End If


            


If InStr (1, TagList, ";" & Strtagname & ";", vbTextCompare) > 0 Then


bremove = True


If bsearchforblock Then


If InStr (1, Blocktaglist, ";" & Strtagname & ";", vbTextCompare) > 0 Then


NPos2 = Len (strText)


nPos3 = InStr (nPos1 + 1, strText, "</" & Strtagname, vbTextCompare)


If nPos3 > 0 Then


nPos3 = InStr (nPos3 + 1, strText, ">")


End If


                        


If nPos3 > 0 Then


NPos2 = NPos3


End If


End If


End If


Else


bremove = False


End If


            


If bremove Then


strresult = strresult & Left (StrText, npos1-1)


StrText = Mid (StrText, NPos2 + 1)


Else


strresult = Strresult & Left (StrText, NPOS1)


StrText = Mid (StrText, NPOS1 + 1)


End If


Else


strresult = strresult & StrText


StrText = ""


End If


        


nPos1 = InStr (StrText, "<")


Loop


strresult = strresult & StrText


   


removehtml = Strresult


End Function





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.