in reply to html tag matching confusion
You'll notice that we don't really need to look out for the td tag here, as what we want is between font tags. You might need to watch for this. We use \s+ instead of a literal space, because this will catch newlines.my $start = q{<font\s+face='arial,helvetica'\s+size='-2'> }; my $end = q{</font></td>}; my @list; { local $\ = ""; # file slurping mode my $filecontents = <>; # take in the whole file @list = ($filecontents =~ /$start(.*?)$end/sg); } print "\n\n\nDOODAH: @list\n";
Using the /s modifier on our regular expression allows . to match newlines as well.
Calling the regular expression in a list context, and using the /g modifier will ensure that all possible matches are stored in our array @list. Likewise using q{} to quote our variables means that we don't need to worry about their contents.
This code works for me on the snippet of html that you provided.
Good luck.
|
|---|