截字符串 去除HTML标记
时间:2023-07-29 17:01:08
<%
'**************************************************
'函数名:gotTopic
'作 用:截字符串,汉字一个算两个字符,英文算一个字符
'参 数:str ----原字符串
' strlen ----截取长度
'返回值:截取后的字符串
'**************************************************
function gotTopic(str,strlen)
if str="" then
gotTopic=""
exit function
end if
dim l,t,c, i
str=replace(replace(replace(replace(str," "," "),""",chr(34)),">",">"),"<","<")
str=replace(str,"?","")
l=len(str)
t=0
for i=1 to l
c=Abs(Asc(Mid(str,i,1)))
if c>255 then
t=t+2
else
t=t+1
end if
if t>=strlen then
gotTopic=left(str,i) & "…"
exit for
else
gotTopic=str
end if
next
gotTopic=replace(replace(replace(replace(gotTopic," "," "),chr(34),"""),">",">"),"<","<")
end function
'=========================================================
'函数:RemoveHTML(strHTML)
'功能:去除HTML标记
'参数:strHTML --要去除HTML标记的字符串
'=========================================================
Function RemoveHTML(strHTML)
Dim objRegExp, Match, Matches
Set objRegExp = New Regexp
objRegExp.IgnoreCase = True
objRegExp.Global = True
'取闭合的<>
objRegExp.Pattern = "<.+?>"
'进行匹配
Set Matches = objRegExp.Execute(strHTML)
' 遍历匹配集合,并替换掉匹配的项目
For Each Match in Matches
strHtml=Replace(strHTML,Match.Value,"")
Next
RemoveHTML=strHTML
Set objRegExp = Nothing
set Matches=nothing
End Function
%>
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
刷新页面的几种方法小结(JS,ASP.NET)
Python高级特性之闭包与装饰器实例详解
![](https://img.aspxhome.com/file/2023/3/65473_0s.png)
WebStorm 遇到的问题总结
![](https://img.aspxhome.com/file/2023/5/132295_0s.gif)
Python OpenCV实现姿态识别的详细代码
![](https://img.aspxhome.com/file/2023/9/78719_0s.jpg)
python使用Plotly绘图工具绘制散点图、线形图
![](https://img.aspxhome.com/file/2023/7/78607_0s.png)
python中使用asyncio实现异步IO实例分析
Python Pandas 如何shuffle(打乱)数据
![](https://img.aspxhome.com/file/2023/5/95855_0s.png)
MySQL基础教程之事务异常情况
![](https://img.aspxhome.com/file/2023/8/128058_0s.jpg)
python使用rsa非对称加密过程解析
![](https://img.aspxhome.com/file/2023/1/77761_0s.png)
客户体验
Python写的Tkinter程序屏幕居中方法
使用c#构造date数据类型
JavaScript性能优化小技巧,创建文档碎片
Python OpenCV实战之与机器学习的碰撞
![](https://img.aspxhome.com/file/2023/6/133466_0s.png)
vue3配置全局参数(挂载全局方法)以及组件的使用
![](https://img.aspxhome.com/file/2023/2/139782_0s.jpg)
将数据插入到MySQL表中的详细教程
基于信息排序的信息理解
![](https://img.aspxhome.com/file/UploadPic/20085/16/2008516103959993s.gif)
python 实现检验33品种数据是否是正态分布
5分钟了解MySQL5.7中union all用法的黑科技
![](https://img.aspxhome.com/file/2023/5/78215_0s.jpg)