欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

asp下去除超链接的函数

程序员文章站 2022-05-31 12:41:50
复制代码 代码如下:<% function replaceurl2(htmlstr) dim n,str1,str2,str3,str4 htmlstr = lcas...

复制代码 代码如下:

<%
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