in reply to Re: capturing between divs
in thread capturing between divs
"If you're not using an HTML parser, you will have much more brittle code."
..of course if you don't understand how the parser works then you're no better off than if you used a simple regexp in the first place.
Try this for size:
while ( $html =~ m{<div[^>]*>(.*?)</div>}sgi ) { my $inside_div = $1; # process contents of $inside_div ... }
This regexp simply looks for content between div tags. It does not support nested divs.. but if you want complex parsing you're better off using a complex parser.
The regexp has the s (multi-line), g (global), and i (case-insensitive) flags set.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: capturing between divs
by Your Mother (Archbishop) on Apr 13, 2009 at 06:18 UTC |