Regex problem - please help.

K

Krakatioison

My problem is simple, but I spent lot of time playing with regex and I am
going nuts.

I need to automatically (many times per day) extract HEADING and
DESCRIPTION from the html code below?


HTML CODE:

<a href="http://www.mylink.com">HEADING</a><br>DESCRIPTION<br>


I am able to get the link already using this regex command:
"a.*href\s*=\s*(?:""(?<1>[^""]*)""|(?<1>\S+))"

Can someone write REGEX command to get HEADING and DESCRIPTION.


Please, it would be really appreciated.

K.
 
K

Ken Tucker [MVP]

Hi,

Check out regexlib.org. Has a ability to search for regex and link
to the regulator a regex tester.

http://www.regexlib.com/Default.aspx
http://www.regexlib.com/Search.aspx?k=html


Ken
---------------------
My problem is simple, but I spent lot of time playing with regex and I am
going nuts.

I need to automatically (many times per day) extract HEADING and
DESCRIPTION from the html code below?


HTML CODE:

<a href="http://www.mylink.com">HEADING</a><br>DESCRIPTION<br>


I am able to get the link already using this regex command:
"a.*href\s*=\s*(?:""(?<1>[^""]*)""|(?<1>\S+))"

Can someone write REGEX command to get HEADING and DESCRIPTION.


Please, it would be really appreciated.

K.
 
K

Krakatioison

This I already went to... hm..
I guess there is no one who can fix me with the code, just by looking at it.
K.
 
J

Jared

Krakatioison,
This one should work, I tested it against the sample you provided. You
may want to include the ignore case option. Let me know how that works out
for you.
Jared

(?:<a\s+href=[\"\'](?<Link>.+?)[\"\'>]+(?<Heading>(\w+))</a>(<(\w+)>)(?<Description>.*)\2)

Krakatioison said:
This I already went to... hm..
I guess there is no one who can fix me with the code, just by looking at
it.
K.


Ken Tucker said:
Hi,

Check out regexlib.org. Has a ability to search for regex and link
to the regulator a regex tester.

http://www.regexlib.com/Default.aspx
http://www.regexlib.com/Search.aspx?k=html


Ken
---------------------
My problem is simple, but I spent lot of time playing with regex and I am
going nuts.

I need to automatically (many times per day) extract HEADING and
DESCRIPTION from the html code below?


HTML CODE:

<a href="http://www.mylink.com">HEADING</a><br>DESCRIPTION<br>


I am able to get the link already using this regex command:
"a.*href\s*=\s*(?:""(?<1>[^""]*)""|(?<1>\S+))"

Can someone write REGEX command to get HEADING and DESCRIPTION.


Please, it would be really appreciated.

K.
 
K

Krakatioison

Jared,
thanks a lot for the time you spent with this.
I'll test it and get back to you
k.




Jared said:
Krakatioison,
This one should work, I tested it against the sample you provided. You
may want to include the ignore case option. Let me know how that works out
for you.
Jared
(?: said:
Krakatioison said:
This I already went to... hm..
I guess there is no one who can fix me with the code, just by looking at
it.
K.


Ken Tucker said:
Hi,

Check out regexlib.org. Has a ability to search for regex and link
to the regulator a regex tester.

http://www.regexlib.com/Default.aspx
http://www.regexlib.com/Search.aspx?k=html


Ken
---------------------
My problem is simple, but I spent lot of time playing with regex and I am
going nuts.

I need to automatically (many times per day) extract HEADING and
DESCRIPTION from the html code below?


HTML CODE:

<a href="http://www.mylink.com">HEADING</a><br>DESCRIPTION<br>


I am able to get the link already using this regex command:
"a.*href\s*=\s*(?:""(?<1>[^""]*)""|(?<1>\S+))"

Can someone write REGEX command to get HEADING and DESCRIPTION.


Please, it would be really appreciated.

K.
 

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

Similar Threads

Regex help needed 1
Regex to retain only the HTML body 1
Help with regular expression 2
Regex Help 1
Regex help! 3
Regex references 4
About Regular Expressions 1
.NET Regex href 1

Top