asp下去除超链接的函数

编程学习 2021-07-05 10:58www.dzhlxh.cn编程入门
有时候我们需要去除网页中的超链接,那么就可以使用狼蚁网站SEO优化的代码了

代码如下:

<%
Function ReplaceUrl2(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>","")
ReplaceUrl2 = HTMLstr
Next
End Function
%>


正则表达式去除链接:

代码如下:

Function RegRemoveHref(HTMLstr)
Set ra = New RegExp
ra.IgnoreCase = True
ra.Global = True
ra.Pattern = "<A[^>]+>(.+?)<\/A>"
RegRemoveHref = ra.replace(HTMLstr,"$1")
END Function

Copyright © 2016-2025 www.dzhlxh.cn 金源码 版权所有 Power by

网站模板下载|网络推广|微博营销|seo优化|视频营销|网络营销|微信营销|网站建设|织梦模板|小程序模板