年年我发



返回   年年我发 > 网站建设 > 代码交流
用户名
密码
 
注册账号 论坛帮助 会员列表 日历事件网赚工具 标记版面已读

代码交流 ASP,PHP,JSP等网站源代码下载与交流。

回复
 
主题工具 搜索本主题 显示模式
  #1   IP: 222.76.215.18
旧 2008-03-14, 11:43 AM
smiling smiling 当前离线
高级会员
 
注册日期: 2006-02-12
帖子: 528
现金: 3821 元
资产: 3821 元
声望: 10 smiling 正向着好的方向发展
默认 asp去除所有的超级链接的两种方法 替换与正则

<%
'******************************
'函数:RemoveHref_A(HTMLstr)
'参数:HTMLstr,待去除链接的字符串
'作者:阿里西西
'日期:2007/7/12
'描述:去除字符串中所有的超级链接
'示例:<%=RemoveHref_A("<a href=/abc/h.html>测试</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
%>
通过正则去除字符串中所有的超级链接
<%
'******************************
'函数:RegRemoveHref(HTMLstr)
'参数:HTMLstr,待去除链接的字符串
'作者:阿里西西
'日期:2007/7/12
'描述:通过正则去除字符串中所有的超级链接
'示例:<%=RegRemoveHref("<a href=/abc/h.html>测试</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
%>
回复时引用此帖

wellcome to www.0058.net
回复


当前查看此主题的会员: 1 (0 位会员和 1 位游客)
 
主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

论坛启用 BB 代码
论坛禁用 表情符号
论坛启用 [IMG] 代码
论坛禁用 HTML 代码
论坛跳转


所有时间均为北京时间. 现在的时间是 04:52 AM, Free Patent & Patent Ideas


Powered by vBulletin 3.5.2 Chinese Exhibition Happy New Year
©2000 - 2008,Jelsoft Enterprises Ltd  Desiccant Molecular Sieve Weight Loss Bentonite Trade Manager