道招

asp正则式获取网页链接和标题

如果您发现本文排版有问题,可以先点击下面的链接切换至老版进行查看!!!

asp正则式获取网页链接和标题

假设有如下字符串:

strSource="<a href='http://www.callcenter.com/viewNewsDetail.asp?ID=10873&classID=3' title='广发银行信用卡中心外呼团'><span class='text-main'>[09/11]</span>广发银行信用卡中心外呼团</a>"

现在,需要提取 href 后面的网址和链接的文字。 ASP的实现

<%
Dim str, reg, objMatches
str = strSource
Set reg = new RegExp
reg.IgnoreCase = True
reg.Global = True
reg.Pattern = "http://([^\s]+)"".+?span.+?\[(.+?)\].+?>(.+?)<"
Set objMatches = reg.Execute(str)
If objMatches.Count > 0 Then
Response.Write("网址:")
Response.Write(objMatches(0).SubMatches(0))
Response.Write("<br>")
Response.Write("标题:")
Response.Write(objMatches(0).SubMatches(2))
End If
%>

以上代码参考了网上信息,有兴趣者可以测试!

Original resource

更新时间:
上一篇:html网页转义符下一篇:asp指定格式显示系统日期和时间FormatDateTime函数

相关文章

String.prototype.match到底怎么用

今天在一本书《Javascript for impatient programmers》上看到写的是这样用 match(regExp: string | RegExp): RegExpMatc 阅读更多…

关注道招网公众帐号
友情链接
消息推送
道招网关注互联网,分享IT资讯,前沿科技、编程技术,是否允许文章更新后推送通知消息。
允许
不用了