国产探花免费观看_亚洲丰满少妇自慰呻吟_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 %> 

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 武汉市| 志丹县| 克山县| 任丘市| 镇江市| 镇雄县| 武宣县| 北流市| 荃湾区| 海宁市| 淅川县| 自治县| 苏尼特右旗| 石泉县| 江川县| 泌阳县| 平邑县| 双鸭山市| 永登县| 嫩江县| 尼玛县| 顺昌县| 鸡东县| 保山市| 四子王旗| 紫金县| 奇台县| 丰县| 黄梅县| 汉中市| 南和县| 永泰县| 西乌珠穆沁旗| 鹤峰县| 通许县| 淮南市| 阿坝县| 甘南县| 嫩江县| 延边| 苗栗县|