有一个字符串里头有许多这种格式的a标签<a href="http://qd.anjuke.com" class="">青岛</a>当然内容是不同的,尝试了这个正则表达式:<a\s+href=\"(.+)\"\s+class=\"\">(.+).*</a> 获取到了 网址和城市名称,但是只能获取到第一个a标签中的内容,请问想要获取所有a标签里的网址和城市名称改怎么做?
对了,我用的是C#,如果有办法的话请将代码详细贴出
正则表达式:<a[\s\S]+?href=\"([\s\S]*?)\"[\s\S]*?>([\s\S]*?)</a>
C#正则表达式:<a[\\s\\S]+?href=\"([\\s\\S]*?)\"[\\s\\S]*?>([\\s\\S]*?)</a>
因为字符串中含有大量超链接,而百度知道一般不允许发布超链接,所以我给你个C#的小例子:
using System;运行结果:
xxxxxx 新闻
xxxxx 青岛