Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
<div id="iwant"> <div id="insideiwant"> </div> </div> <div id="nowant"> </div>
I want to get the contents of the first outter div block (with id "iwant").
However there may be more div blocks after the iwant block. Thus I can't use greedy regex because it will pick up all the div blocks, not just the section i want.
The id tags are there just for the sake of identification. In a real world example, there would be no way to differentiate div blocks besides the heirarchy of the html.
I figure maybe something with lookaheads might do it but I'm just barely into learning how to use lookaheads and the like.
Thanks.
-MN
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(jeffa) Re: Parsing nested HTML with just regex
by jeffa (Bishop) on Jul 23, 2003 at 15:42 UTC | |
|
Re: Parsing nested HTML with just regex
by dragonchild (Archbishop) on Jul 23, 2003 at 15:25 UTC | |
|
Re: Parsing nested HTML with just regex
by Abigail-II (Bishop) on Jul 23, 2003 at 19:48 UTC | |
|
Re: Parsing nested HTML with just regex
by Anonymous Monk on Jul 23, 2003 at 15:31 UTC |