<h3><a href="这里是链接1" target="_blank" id="">这里是链接的标题1</a></h3>
<h3><a href="这里是链接2" target="_blank" id="">这里是链接的标题2</a></h3>
格式如上所述,现在我想要获取链接跟标题(PS:也就是html文档中h3标签中A标签的内容),正则要怎么写呢?
string pattern = "<h3><a[^<]*href=\"([^<]*?)\"[^<]*>(.*?)</a></h3>"; string html="<h3><a href=\"这里是链接1\" target=\"_blank\" id=\"\">这里是链接的标题1</a></h3>"; var m = Regex.Match(html, pattern); string href = m.Groups[1].Value; string title = m.Groups[2].Value;
谢谢!