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

首頁 > 編程 > regex > 正文

截字符串 去除HTML標記

2020-01-20 22:31:11
字體:
來源:轉載
供稿:網友
<%
'**************************************************
'函數名: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
%>
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 上犹县| 台州市| 北川| 都江堰市| 丹江口市| 营口市| 林周县| 黎城县| 上杭县| 大同县| 定结县| 云浮市| 牡丹江市| 诏安县| 耿马| 登封市| 富川| 应城市| 唐海县| 洛宁县| 远安县| 东丽区| 岳西县| 宜阳县| 囊谦县| 抚宁县| 山丹县| 湟源县| 永川市| 高密市| 西平县| 陵川县| 平武县| 拜城县| 获嘉县| 云林县| 宣化县| 广南县| 定西市| 禄丰县| 北流市|