ASP function code analysis for removing HTML is attached with examples. It has been tested by Script Home programming and is indeed easy to use.
The following code will not replace the < in the middle of ld<sad, so the content is still normal.
The code is as follows:
<%
function nohtml(str)
dim re
Set re=new RegExp
re.IgnoreCase =true
re.Global=True
re.Pattern=(/<.[^/<]*/>)
str=re.replace(str, )
re.Pattern=(/<//[^/<]*/>)
str=re.replace(str, )
str=replace(str, ,)
str=replace(str, ,)
nohtml=str
set re=nothing
end function
str=<title>sadjksjdl script home welcomes you sajdljsald<sadsadsad<br> 'This is a test
response.write nohtml(str)
%>
The result is:
The code is as follows:
sadjksjdl script home welcomes you sajdljsald<sadsadsad
However, the following code does not ask. Just see < and forget about the unlimited matching behind it.
The code is as follows:
<%
Function dropHtml(Byval strHTML)
Dim objRegExp, Match, Matches
Set objRegExp = New Regexp
objRegExp.IgnoreCase = True
objRegExp.Global = True
'Get the closed <>
objRegExp.Pattern = <.+?>
'Match
Set Matches = objRegExp.Execute(strHTML)
' Traverse the matching set and replace matching items
For Each Match in Matches
strHtml=Replace(strHTML,Match.Value,)
Next
dropHtml=strHTML
Set objRegExp = Nothing
End Function
str=<title>sadjksjdl script home welcomes you sajdljsald<sadsadsad<br> 'This is a test
response.write dropHtml(str)
%>
The result is:
The code is as follows:
sadjksjdl script home welcomes you sajdljsald