Rodster001 has asked for the wisdom of the Perl Monks concerning the following question:
What I want is to end up with an @array with List 1 in $array[0] and List 2 in $array[1]. The sub items is what is tripping me up.<ul> <li> List 1 Item 1 <li> List 1 Item 2 <ul> <li> Sub-Item 1 <li> Sub-Item 2 </ul> <li> List 1 Item 3 </ul> <ul> <li> List 2 Item 1 <li> List 2 Item 2 <ul> <li> Sub-Item 1 <li> Sub-Item 2 </ul> <li> List 2 Item 3 </ul>
Right now I am splitting the string on line breaks and using a foreach loop to find and skip nested items and push them into respective array elements.
My question is: Can I accomplish this same thing with a single regex?
Thanks for your help!
--Rod
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Regex Nested Matching
by ssandv (Hermit) on Feb 24, 2010 at 20:12 UTC | |
by Rodster001 (Pilgrim) on Feb 24, 2010 at 22:33 UTC | |
by SuicideJunkie (Vicar) on Feb 25, 2010 at 14:41 UTC | |
Re: Regex Nested Matching
by xyzzy (Pilgrim) on Feb 24, 2010 at 19:09 UTC | |
Re: Regex Nested Matching
by drblove27 (Sexton) on Feb 24, 2010 at 19:43 UTC |