1

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');">ToolStripItemOwnerCollectionUIAdapter.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

Fumiko
  • 9
  • 1
  • 2

1 Answers1

1
/<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.

Sean Patrick Floyd
  • 292,901
  • 67
  • 465
  • 588