Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I need to match the following
What I have so far is<li><a class="style5" href="http://www.site.com/page.html"> some words here</a> - <a class="style3" href="http://www.site.com/page2.html"> "some words here"</a> </li>
What I need to match: $1 = the text inside the first link's text, $2 = the 2nd link's URL, $3 - the 2nd link's text.push (@results, "$1::$2::$3"), $result_content =~ m#style="5" href +=".+">\s+(.+)?</a>\s+-\s+\<a class="style3" href="(.+)?">(.+)?</a>#gi +s;
The links can be any links, so I'm not literally matching for this one, of course. Sometimes there are quotes in the 2nd link's text, sometimes it's a ' instead of ", so I just want to match whatever is in that text part. There are infinitely many of these.
If someone can show me how to fix this I'd be very much appreciative. Also if someone can show me how to do this with one of those modules people use for HTML regexes so it's more stable, I'd be very interested to see how it's done.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: 3 capture multi line regex
by Fletch (Bishop) on Jun 30, 2006 at 17:55 UTC | |
|
Re: 3 capture multi line regex
by Ieronim (Friar) on Jun 30, 2006 at 18:12 UTC | |
by Anonymous Monk on Jun 30, 2006 at 18:23 UTC | |
by Ieronim (Friar) on Jun 30, 2006 at 18:44 UTC | |
by Anonymous Monk on Jun 30, 2006 at 20:34 UTC | |
by Ieronim (Friar) on Jun 30, 2006 at 21:40 UTC | |
| |
|
Re: 3 capture multi line regex
by wfsp (Abbot) on Jul 01, 2006 at 06:15 UTC |