473,394 Members | 1,887 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,394 software developers and data experts.

Retrieve tag A from html

Hi.

I need a regular expression to extract all tag A from HTML
code. I need the href and text as two disting objects.

Suggestions?

Thx! ;-)
Matteo Migliore.
Oct 5 '07 #1
4 1763
Matteo Migliore wrote:
I need a regular expression to extract all tag A from HTML
code. I need the href and text as two disting objects.
Why do you want to use regular expressions to parse HTML when there are
APIs for that like SgmlReader
<URL:http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=B90FDDCE-E60D-43F8-A5C4-C3BD760564BC>
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Oct 5 '07 #2
Why do you want to use regular expressions to parse HTML when there
are APIs for that like SgmlReader
Thanks! I see SqmlReader but for my problem is too much
and I prefer to use .NET classes and RegEx.

I downloaded the project but i don't like it very much :-).

Thx! ;-)
Matteo Migliore.
Oct 5 '07 #3
Hi,

All you have to do is get the text from "<a" and up to "</a>"

"Matteo Migliore" <ma*****************@gmail.comwrote in message
news:Oq**************@TK2MSFTNGP02.phx.gbl...
Hi.

I need a regular expression to extract all tag A from HTML
code. I need the href and text as two disting objects.

Suggestions?

Thx! ;-)
Matteo Migliore.

Oct 5 '07 #4
Hello Ignacio Machin ( .NET/ C# MVP )" machin TA laceupsolutions.com,
Hi,

All you have to do is get the text from "<a" and up to "</a>"

"Matteo Migliore" <ma*****************@gmail.comwrote in message
news:Oq**************@TK2MSFTNGP02.phx.gbl...
>Hi.

I need a regular expression to extract all tag A from HTML code. I
need the href and text as two disting objects.

Suggestions?

Thx! ;-)
Matteo Migliore.
Which would come down to something like this:

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

It would save the href to a group named href and the text to a group named
text.

--
Jesse Houwing
jesse.houwing at sogeti.nl
Oct 5 '07 #5

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

Similar topics

5
by: Info 3000 | last post by:
Hi there, Simple question, but headache ! I have a PHP Page like : <HTML> <HEAD> <TITLE>Sunny day !</TITLE> </HEAD>
0
by: Chung Leong | last post by:
My contribution to the comp.lang.php FAQ: ------------------------------------------------------------- Q: How do I retrieve a page from a web site? A: Pass a URL to file() or...
5
by: David Rasmussen | last post by:
Some sites seem to be session driven in the sense that if I visit the homepage and do a few clicks I can navigate anywhere I want, but if I paste the current location into a new browser window...
1
by: Eugfene | last post by:
I have the following function in a html file: function selectEdit(fileID, processCode, processID, fileName,fileDesc) { document.forms.recordID.value = fileID; document.forms.processor.value =...
2
by: Frank | last post by:
Can I do this? I add a session var in C# and ultimatly want to pass it into a vbscript client side activeX control. This is what I have so far but get " Object Required:'name2' " error. Can...
2
by: * Tong * | last post by:
Hi, I'm wondering if you can show me an example php page that allows me to retrieve and display 3rd party pages. I.e., when my php script is called as http://site/path/getit.php?file_key it...
13
by: kev | last post by:
Hi all, I have created a database for equipments. I have a form to register the equipment meaning filling in all the particulars (ID, serial, type, location etc). I have two buttons at the end...
3
by: karthigaj | last post by:
Hi, Happy new Year... i need to retrieve the data from the web server which is developed using HTML and i need to process those data in c but i should not use any CGIs. Can anybody help me...
3
by: Alfred | last post by:
I want to post text field data from these HTML TEXTAREA tags to a PostgreSQL database and have it reappear back on another page exactly as I had typed it. Over the years I have done this but only...
4
by: kang jia | last post by:
hi i am doing mailinglist currently. the code in my first page is like this : : <html> <head> <link rel="stylesheet" type="text/css" href="gallery.css" /> <script language="JavaScript"> ...
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.