去除內(nèi)容中的html
更新時(shí)間:2006年06月14日 00:00:00 作者:
<%
Option Explicit
Function stripHTML(strtext)
dim arysplit,i,j, strOutput
arysplit=split(strtext,"<")
if len(arysplit(0))>0 then j=1 else j=0
for i=j to ubound(arysplit)
if instr(arysplit(i),">") then
arysplit(i)=mid(arysplit(i),instr(arysplit(i),">")+1)
else
arysplit(i)="<" & arysplit(i)
end if
next
strOutput = join(arysplit, "")
strOutput = mid(strOutput, 2-j)
strOutput = replace(strOutput,">",">")
strOutput = replace(strOutput,"<","<")
stripHTML = strOutput
End Function
%>
<form method="post" id=form1 name=form1>
<b>Enter an HTML String:</b><br>
<textarea name="txtHTML" cols="50" rows="8" wrap="virtual"><%=Request("txtHTML")%></textarea>
<p>
<input type="submit" value="Strip HTML Tags!" id=submit1 name=submit1>
</form>
<% if Len(Request("txtHTML")) > 0 then %>
<p><hr><p>
<b><u>View of string <i>with no</i> HTML stripping:</u></b><br>
<xmp>
<%=Request("txtHTML")%>
</xmp><p>
<b><u>View of string <i>with</i> HTML stripping:</u></b><br>
<pre>
<%=StripHTML(Request("txtHTML"))%>
</pre>
<% End If %>
Option Explicit
Function stripHTML(strtext)
dim arysplit,i,j, strOutput
arysplit=split(strtext,"<")
if len(arysplit(0))>0 then j=1 else j=0
for i=j to ubound(arysplit)
if instr(arysplit(i),">") then
arysplit(i)=mid(arysplit(i),instr(arysplit(i),">")+1)
else
arysplit(i)="<" & arysplit(i)
end if
next
strOutput = join(arysplit, "")
strOutput = mid(strOutput, 2-j)
strOutput = replace(strOutput,">",">")
strOutput = replace(strOutput,"<","<")
stripHTML = strOutput
End Function
%>
<form method="post" id=form1 name=form1>
<b>Enter an HTML String:</b><br>
<textarea name="txtHTML" cols="50" rows="8" wrap="virtual"><%=Request("txtHTML")%></textarea>
<p>
<input type="submit" value="Strip HTML Tags!" id=submit1 name=submit1>
</form>
<% if Len(Request("txtHTML")) > 0 then %>
<p><hr><p>
<b><u>View of string <i>with no</i> HTML stripping:</u></b><br>
<xmp>
<%=Request("txtHTML")%>
</xmp><p>
<b><u>View of string <i>with</i> HTML stripping:</u></b><br>
<pre>
<%=StripHTML(Request("txtHTML"))%>
</pre>
<% End If %>
相關(guān)文章
學(xué)習(xí)正則表達(dá)式30分鐘入門教程(第二版)
30分鐘內(nèi)讓你明白正則表達(dá)式是什么,并對(duì)它有一些基本的了解,讓你可以在自己的程序或網(wǎng)頁里使用它2007-03-03使用正則表達(dá)式驗(yàn)證登錄頁面輸入是否符合要求
這篇文章主要介紹了使用正則表達(dá)式驗(yàn)證登錄頁面輸入是否符合要求的實(shí)例代碼,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2017-09-09asp提取內(nèi)容中的手機(jī)號(hào)碼,qq,網(wǎng)址的正則代碼
有時(shí)候需要獲取頁面源代碼中的手機(jī)號(hào)碼,qq,網(wǎng)址,一般情況下都是用正則表達(dá)式實(shí)現(xiàn)的,需要的朋友可以參考下。2011-09-09js正則表達(dá)式之RegExp對(duì)象之compile方法 編譯正則表達(dá)式
該方法可以編譯指定的正則表達(dá)式,編譯之后的正則表達(dá)式執(zhí)行速度將會(huì)提高,如果正則表達(dá)式多次被調(diào)用,那么調(diào)用compile方法可以有效的提高代碼的執(zhí)行速度,如果該正則表達(dá)式只能被使用一次,則不會(huì)有明顯的效果2012-10-10