473,387 Members | 1,290 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Regex expression to get href value in c#

Hi,

I want to parse html with multiple <a href.. text...</atags 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</atag.

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

Jul 4 '06 #1
1 6631
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

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Indian Offshore Company" wrote:
Hi,

I want to parse html with multiple <a href.. text...</atags 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</atag.

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

Jul 4 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: alphatan | last post by:
Is there relative source or document for this purpose? I've searched the index of "Mastering Regular Expression", but cannot get the useful information for C. Thanks in advanced. -- Learning...
2
by: Ginola | last post by:
Hi, I have a beginner of C# and I need to fix the bug for someone!! I have the codes like this Regex re = new Regex(@"<TR VALIGN=top><TD></TD>.*?</TD></TR>"); MatchCollection theMatches =...
17
by: clintonG | last post by:
I'm using an .aspx tool I found at but as nice as the interface is I think I need to consider using others. Some can generate C# I understand. Your preferences please... <%= Clinton Gallagher ...
13
by: The Cleaning Wonder Boy | last post by:
Could someone please explain to me what the (?<Key> and (?<Value> are in the following Regex expression? This gets relative links in an HTML string (file). ...
2
by: .NET Developer | last post by:
Hello, I'm trying to write a RegEx that will find all occurances of a particular type of HTML anchor <a> element in a big block of HTML. Here are the pattern requirements - they consist of certain...
17
by: Mark | last post by:
I must create a routine that finds tokens in small, arbitrary VB code snippets. For example, it might have to find all occurrences of {Formula} I was thinking that using regular expressions...
6
by: Martin Evans | last post by:
Sorry, yet another REGEX question. I've been struggling with trying to get a regular expression to do the following example in Python: Search and replace all instances of "sleeping" with "dead"....
9
by: jmchadha | last post by:
I have got the following html: "something in html ... etc.. city1... etc... <a class="font1" href="city1.html" onclick="etc."click for <b>info</bon city1 </a> ... some html. city1.. can repeat...
4
by: pedrito | last post by:
I have a regex question and it never occurred to me to ask here, until I saw Jesse Houwing's quick response to Phil for his Regex question. I have some filenames that I'm trying to parse out of...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.