Page 1 of 1

How ot formulate a REGEX for this?

Posted: Sat May 23, 2009 6:09 am
by wren9
Hi
Let say i have an html codes below,

Code: Select all

 
<html>
<head>
</head>
 
<body>
<h4>this is H4 heading one</h4>
    <a href="domain.com">one</a>
    <a href="domain.com">two</a>
    <a href="domain.com">three</a>
<h4>this is H4 heading two</h4>
</body>
</html>
 
What i want is to get all the link between H4 heading one and H4 heading two.

Can you show me the right REGEX syntax for this please.

Thank you in advance.

Re: How ot formulate a REGEX for this?

Posted: Sat May 23, 2009 6:24 am
by prometheuzz
You didn't mention that there can be links outside these tags, so this regex will work just fine:

Code: Select all

'/(?<==")[^"]+(?=")/'

Re: How ot formulate a REGEX for this?

Posted: Sat May 23, 2009 6:43 am
by wren9
prometheuzz wrote:You didn't mention that there can be links outside these tags, so this regex will work just fine:

Code: Select all

'/(?<==")[^"]+(?=")/'

You are correct, there is links outside.

can you show me that too please.

Thank you.

Re: How ot formulate a REGEX for this?

Posted: Sat May 23, 2009 7:12 am
by prometheuzz
wren9 wrote:
prometheuzz wrote:You didn't mention that there can be links outside these tags, so this regex will work just fine:

Code: Select all

'/(?<==")[^"]+(?=")/'

You are correct, there is links outside.

can you show me that too please.

Thank you.
Well, I can help you with it. What have you tried yourself so far?