Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.26 KB | None | 0 0
  1. Const ForReading = 1
  2. Const ForWriting = 2
  3.  
  4. Set objFSO = CreateObject("Scripting.FileSystemObject")
  5. Set objFile = objFSO.OpenTextFile("event2.txt", ForReading)
  6.  
  7. strEventIn = objFile.ReadAll
  8. objFile.Close
  9.  
  10. Function RemoveHTML( strText )
  11. Dim TAGLIST
  12. TAGLIST = ";!--;!DOCTYPE;A;ACRONYM;ADDRESS;APPLET;AREA;B;BASE;BASEFONT;" &_
  13. "BGSOUND;BIG;BLOCKQUOTE;BODY;BR;BUTTON;CAPTION;CENTER;CITE;CODE;" &_
  14. "COL;COLGROUP;COMMENT;DD;DEL;DFN;DIR;DIV;DL;DT;EM;EMBED;FIELDSET;" &_
  15. "FONT;FORM;FRAME;FRAMESET;HEAD;H1;H2;H3;H4;H5;H6;HR;HTML;I;IFRAME;IMG;" &_
  16. "INPUT;INS;ISINDEX;KBD;LABEL;LAYER;LAGEND;LI;LINK;LISTING;MAP;MARQUEE;" &_
  17. "MENU;META;NOBR;NOFRAMES;NOSCRIPT;OBJECT;OL;OPTION;P;PARAM;PLAINTEXT;" &_
  18. "PRE;Q;S;SAMP;SCRIPT;SELECT;SMALL;SPAN;STRIKE;STRONG;STYLE;SUB;SUP;" &_
  19. "TABLE;TBODY;TD;TEXTAREA;TFOOT;TH;THEAD;TITLE;TR;TT;U;UL;VAR;WBR;XMP;"
  20.  
  21. Const BLOCKTAGLIST = ";APPLET;EMBED;FRAMESET;HEAD;NOFRAMES;NOSCRIPT;OBJECT;SCRIPT;STYLE;"
  22.  
  23. Dim nPos1
  24. Dim nPos2
  25. Dim nPos3
  26. Dim strResult
  27. Dim strTagName
  28. Dim bRemove
  29. Dim bSearchForBlock
  30.  
  31. nPos1 = InStr(strText, "<")
  32. Do While nPos1 > 0
  33. nPos2 = InStr(nPos1 + 1, strText, ">")
  34. If nPos2 > 0 Then
  35. strTagName = Mid(strText, nPos1 + 1, nPos2 - nPos1 - 1)
  36. strTagName = Replace(Replace(strTagName, vbCr, " "), vbLf, " ")
  37.  
  38. nPos3 = InStr(strTagName, " ")
  39. If nPos3 > 0 Then
  40. strTagName = Left(strTagName, nPos3 - 1)
  41. End If
  42.  
  43. If Left(strTagName, 1) = "/" Then
  44. strTagName = Mid(strTagName, 2)
  45. bSearchForBlock = False
  46. Else
  47. bSearchForBlock = True
  48. End If
  49.  
  50. If InStr(1, TAGLIST, ";" & strTagName & ";", vbTextCompare) > 0 Then
  51. bRemove = True
  52. If bSearchForBlock Then
  53. If InStr(1, BLOCKTAGLIST, ";" & strTagName & ";", vbTextCompare) > 0 Then
  54. nPos2 = Len(strText)
  55. nPos3 = InStr(nPos1 + 1, strText, "</" & strTagName, vbTextCompare)
  56. If nPos3 > 0 Then
  57. nPos3 = InStr(nPos3 + 1, strText, ">")
  58. End If
  59.  
  60. If nPos3 > 0 Then
  61. nPos2 = nPos3
  62. End If
  63. End If
  64. End If
  65. Else
  66. bRemove = False
  67. End If
  68.  
  69. If bRemove Then
  70. strResult = strResult & Left(strText, nPos1 - 1)
  71. strText = Mid(strText, nPos2 + 1)
  72. Else
  73. strResult = strResult & Left(strText, nPos1)
  74. strText = Mid(strText, nPos1 + 1)
  75. End If
  76. Else
  77. strResult = strResult & strText
  78. strText = ""
  79. End If
  80.  
  81. nPos1 = InStr(strText, "<")
  82. Loop
  83. strResult = strResult & strText
  84.  
  85. RemoveHTML = strResult
  86. End Function
  87.  
  88.  
  89. Set objFile = objFSO.OpenTextFile("event2.txt", ForWriting)
  90. objFile.WriteLine RemoveHTML(objFile.ReadAll)
  91. objFile.Close
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement