Truncate string to remove HTML tags

Time:2022-4-21

<%
‘**************************************************
‘function name: gottopic
‘function: cut string, Chinese characters count as two characters, and English count as one character
‘parameter: STR — original string
‘strlen — intercept 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
‘parameter: strhtml — string to remove HTML tag
‘=========================================================
Function RemoveHTML(strHTML)
Dim objRegExp, Match, Matches
Set objRegExp = New Regexp
objRegExp.IgnoreCase = True
objRegExp.Global = True
‘Take the closed < >
objRegExp.Pattern = “<.+?>”
‘match
Set Matches = objRegExp.Execute(strHTML)
‘traverse the matching set and replace the matching items
For Each Match in Matches
strHtml=Replace(strHTML,Match.Value,””)
Next
RemoveHTML=strHTML
Set objRegExp = Nothing
set Matches=nothing
End Function
%>

Recommended Today

Swift FAQ

1、 Foundation 1. What is the difference between class and struct? a. Struct will automatically generate the required constructor. The constructor with which attribute is not assigned an initial value will be generated with which attribute as the parameter. But class doesn’t. write it yourself struct StructTest { var name:String var age:Int } class ClassTest […]