Regex Help

K

Krakatioison

People,

All I need is one line of code for regex to parse LINK, LINK TEXT and LINK
DESCRIPTION out of this html:

<a class="y" href=http://www.LINK.com>LINK TEXT</a><br><font size="-1"
style="font-family: arial,sans-serif"><b><font color="#6f6f6f"
style="font-family:
arial,sans-serif">Canada.com&nbsp;-</font>15&nbsp;minutes&nbsp;ago</b><br>LI
NK DESCRIPTION <br>

In this case, this should be the result:
Link is: http://www.LINK.com
Link Text is: LINK TEXT
Link Description is: LINK DESCRIPTION

One person suggested this:
(?:<a\s+href=[\"\'](?<Link>.+?)[\"\'>]+(?<Heading>(\w+))</a>(<(\w+)>)(?<Desc
ription>.*)\2)

But it didn't work.

I already spent endless hours trying to write one line of code, it's really
at the end of my knowledge to fix it.

Does someone find a time to aswer me with one single line of regex code
which would do this?

Please.

K.
 
J

Jouni Heikniemi

All I need is one line of code for regex to parse LINK, LINK TEXT and
LINK DESCRIPTION out of this html:

Quite probably that's not what you need. Not really. The regex you asked
for (probably at its simplest and most unreliable form) could be for
example "<a.*?href=([^>]+)>([^<]+).*?<br>([^>]+)<", but that's not a good
nor generic solution. Writing a even relatively generic-purpose HTML code
interpreter is too hard to do with regexps if there's any variance at all
in the source material.
 

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

Top