开发者

How to get two pieces from a link?

The link looks like this

<a href="http://msdn.microsoft.com/en-us/library/Aa538627.aspx" onclick="trackClick(this, '117', 'http\x3a\x2f\x2fmsdn.microsoft.com\x2fen-us\x2flibrary\x2fAa538627.aspx', '15');">To开发者_如何学ColStripItemOwnerCollectionUIAdapter.GetInsertingIndex Method ...</a>

I want to retrieve the link (from href), and get the text in between get this.

Not sure how to do it


/<a[^>]*\s+href\s*=\s*\"([^"]+)"[^>]*>(.*?)</a>/gi

This pattern should match most well-behaved links and provide the URL in group 1 and the text in group 2. For everything more complicated than that use a HTML parser.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜