SoFunction
Updated on 2025-03-10

Cut string Remove HTML tags

<%
'**************************************************
'Function name: gotTopic
'Methods: Cut string, one Chinese character counts two characters, and one character counts one in English
'Arguments: str ----original string
' strlen ----Intercept the length
'Return value: intercepted string
'**************************************************
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
'=========================================================
'Function: RemoveHTML(strHTML)
'Function: Remove HTML tags
'Arguments: strHTML --String to remove HTML tags
'=========================================================
Function RemoveHTML(strHTML)
Dim objRegExp, Match, Matches
Set objRegExp = New Regexp
= True
= True
'Pick the closed<>
= "<.+?>"
'Make a match
Set Matches = (strHTML)
' traverse the matching collection and replace the matching items
For Each Match in Matches
strHtml=Replace(strHTML,,"")
Next
RemoveHTML=strHTML
Set objRegExp = Nothing
set Matches=nothing
End Function
%>