国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Regex > 正文

正則表達式教程:去除內容中的html

2020-03-16 21:24:39
字體:
來源:轉載
供稿:網友
本文將為大家介紹如何使用正則表達式去除文章內容中的HTML代碼。具體代碼如下:

  1. <% 
  2. Option Explicit 
  3.  
  4. Function stripHTML(strtext) 
  5. dim arysplit,i,j, strOutput 
  6. arysplit=split(strtext,"<"
  7.  
  8.   if len(arysplit(0))>0 then j=1 else j=0 
  9.  
  10.   for i=j to ubound(arysplit) 
  11.      if instr(arysplit(i),">") then 
  12.        arysplit(i)=mid(arysplit(i),instr(arysplit(i),">")+1) 
  13.      else 
  14.        arysplit(i)="<" & arysplit(i) 
  15.      end if 
  16.   next 
  17.  
  18.   strOutput = join(arysplit, ""
  19.   strOutput = mid(strOutput, 2-j) 
  20.   strOutput = replace(strOutput,">",">"
  21.   strOutput = replace(strOutput,"<","<"
  22.  
  23.   stripHTML = strOutput 
  24. End Function 
  25.  
  26.  
  27. %> 
  28.  
  29. <form method="post" id=form1 name=form1> 
  30.   <b>Enter an HTML String:</b><br> 
  31.   <textarea name="txtHTML" cols="50" rows="8" wrap="virtual"><%=Request("txtHTML")%></textarea> 
  32.   <p> 
  33.   <input type="submit" value="Strip HTML Tags!" id=submit1 name=submit1> 
  34. </form> 
  35.  
  36. <% if Len(Request("txtHTML")) > 0 then %> 
  37.     <p><hr><p> 
  38.     <b><u>View of string <i>with no</i> HTML stripping:</u></b><br> 
  39.     <xmp> 
  40.     <%=Request("txtHTML")%> 
  41.     </xmp><p> 
  42.     <b><u>View of string <i>with</i> HTML stripping:</u></b><br> 
  43.     <pre> 
  44.     <%=StripHTML(Request("txtHTML"))%> 
  45.     </pre> 
  46. <% End If %> 

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 加查县| 鹿邑县| 衢州市| 海林市| 四会市| 广丰县| 祁门县| 兴义市| 正宁县| 阳信县| 循化| 小金县| 雅安市| 汪清县| 比如县| 鸡西市| 西安市| 共和县| 南溪县| 东方市| 尉氏县| 日土县| 三原县| 中牟县| 徐闻县| 莱州市| 临沂市| 富阳市| 建阳市| 开阳县| 合肥市| 玉环县| 玛纳斯县| 和田县| 东平县| 房山区| 松溪县| 阿克陶县| 渝中区| 武乡县| 乡宁县|