<%
‘**************************************************
‘函數(shù)名:gotTopic
‘作 用:截字符串,漢字一個(gè)算兩個(gè)字符,英文算一個(gè)字符
‘參 數(shù):str —-原字符串
‘ strlen —-截取長(zhǎng)度
‘返回值:截取后的字符串
‘**************************************************
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
‘=========================================================
‘函數(shù):RemoveHTML(strHTML)
‘功能:去除HTML標(biāo)記
‘參數(shù):strHTML –要去除HTML標(biāo)記的字符串
‘=========================================================
Function RemoveHTML(strHTML)
Dim objRegExp, Match, Matches
Set objRegExp = New Regexp
objRegExp.IgnoreCase = True
objRegExp.Global = True
‘取閉合的<>
objRegExp.Pattern = “<.+?>”
‘進(jìn)行匹配
Set Matches = objRegExp.Execute(strHTML)
‘ 遍歷匹配集合,并替換掉匹配的項(xiàng)目
For Each Match in Matches
strHtml=Replace(strHTML,Match.Value,””)
Next
RemoveHTML=strHTML
Set objRegExp = Nothing
set Matches=nothing
End Function
%>
截字符串 去除HTML標(biāo)記
相關(guān)推薦
- 自媒體推廣實(shí)時(shí)監(jiān)控從服務(wù)器帶寬到用戶行為解決方法
- 自媒體人搭建直播服務(wù)器使用raksmart優(yōu)化技巧
- 華納云高防服務(wù)器3.6折起低至1188元/月,企業(yè)級(jí)真實(shí)防御20G`T級(jí),自營(yíng)機(jī)房一手服務(wù)器資源
- 云起無(wú)垠:SecGPT-全球首個(gè)網(wǎng)絡(luò)安全開(kāi)源大模型
- 青云QingCloud:KubeSphere第四季度擴(kuò)展組件開(kāi)發(fā)計(jì)劃
- 雙喜臨門(mén):「DaoCloud 道客」 榮獲 2023 可信云兩項(xiàng)最佳實(shí)踐
- html5實(shí)現(xiàn)圖片的3D旋轉(zhuǎn)效果
- html5中如何制作搜索欄