We may add some hyperlinks in asp, but what should we do if we don’t need them after adding them? Now let’s take a look at the methods to remove all hyperlinks from Asp. If you want to know, please refer to them.
<%
'*********************************
'Function: RemoveHref_A(HTMLstr)
'Arguments: HTMLstr, string to be removed
'Author: Alixi
'Date: 2007/7/12
'Description: Remove all hyperlinks in the string
'Example: <%=RemoveHref_A("<a href=/abc/h.html>test</a>")%>
'*********************************
Function RemoveHref_A(HTMLstr)
Dim n, str1, str2, str3, str4
HTMLstr = Lcase(HTMLstr)
For n=1 to Ubound(Split(HTMLstr,"<a"))
str1 = Instr(HTMLstr,"<a")
str2 = Instr(str1,HTMLstr,">")
HTMLstr = left(HTMLstr,str1-1)&right(HTMLstr,len(HTMLstr)-len(left(HTMLstr,str2)))
HTMLstr = replace (HTMLstr,"</a>","")
RemoveHref_A = HTMLstr
Next
End Function
%>
Regularly remove all hyperlinks in strings
<%
'*********************************
'Function: RegRemoveHref(HTMLstr)
'Arguments: HTMLstr, string to be removed
'Author: Alixi
'Date: 2007/7/12
'Description: Remove all hyperlinks in strings by regular
'Example: <%=RegRemoveHref("<a href=/abc/h.html>test</a>")%>
'*********************************
Function RegRemoveHref(HTMLstr)
Set ra = New RegExp
ra.IgnoreCase = True
ra.Global = True
ra.Pattern = "<a[^>]+>(.+?)<//a>"
RegRemoveHref = ra.replace(HTMLstr,"$1")
END Function
%>
The above is all the content of this article. I hope that the content of this article will be of some help to everyone’s study or work. I also hope to support the wrong new technology channel!