Regex expression to get href value in c#

  • Thread starter Thread starter Indian Offshore Company
  • Start date Start date
I

Indian Offshore Company

Hi,

I want to parse html with multiple <a href> .. text...</a> tags as
follow:

"... some html... <a class="1" href="city1.html" onclick="etc."> click
for info on city1 </a> .. some html.. <a class="1" href="city2.html"
onclick="etc."> click for info on city2 </a> .. etc etc......"

I want to get value of href i.e "city1.html", "city2.html" by searching
"city1" , "city2" respectively between the <a> </a> tag.

I thing by using Regex expression I should be able to achieve this. If
any Regex guru can tell me which Regex can be used for this that would
be of great help to me.

Thanks
Dinesh
 
Indian Offshore Company,

if you need to "scrape" stuff out of HTML pages I'd recommend taking a look
at Simon Mourier's HtmlAgilityPack. This will parse an HTML page into an
"HtmlDocument" class that derives from IXPathNavigable, enabling to use any
XPath expressions you want.
Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top