去除内容中的html
程序员文章站
2022-03-03 11:45:30
<%option explicitfunction striphtml(strtext)dim arysplit,i,j, stroutputarysplit=spl...
<%
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 %>
推荐阅读
-
html5中valid、invalid、required的定义
-
HTML5中的Scoped属性使用实例
-
HTML5中5个简单实用的API(第二篇,含全屏、可见性、拍照、预加载、电池状态)
-
使用jTopo给Html5 Canva中绘制的元素添加鼠标事件
-
HTML5中5个简单实用的API
-
HTML5中的autofocus(自动聚焦)属性介绍
-
PHP字符串函数系列之nl2br(),在字符串中的每个新行 ( ) 之前插入 HTML 换行符br
-
Editplus中的代码怎么直接查看HTML效果?
-
Python实现批量将word转html并将html内容发布至网站的方法
-
详解HTML5中垂直上下居中的解决方案