in reply to Help constructing a regex that also matches hyphens and parentheses

I often find that what starts out as an apparently trivial task of parsing apparantly trivial HTML ends up being very difficult.

Even in this case I would reach for an HTML parser.

#!/usr/bin/perl use warnings; use strict; use HTML::TokeParser::Simple; my @array = <DATA>; for my $line (@array){ my $tp = HTML::TokeParser::Simple->new(\$line); my $cell_data; while (my $t = $tp->get_token){ $cell_data++, next if $t->is_start_tag('td') and $t->get_attr('height') == 40 and $t->get_attr('width') == 40 and $t->get_attr('border') == 0; print $t->as_is if $cell_data and $t->is_text; } } __DATA__ <td width='10' height='40' border='0'>cell data 1</td> <td width='20' height='40' border='0'>cell data 2</td> <td width='30' height='40' border='0'>cell data 3</td> <td width='40' height='40' border='0'>cell data 4</td> <td width='40' height='40' border='0'>cell data 5</td> <td width='40' height='40' border='0'>cell data 6</td> <td width='40' height='40' border='0'>cell data 7</td> <td width='40' height='40' border='0'>cell data 8</td>
Output:

---------- Capture Output ---------- > "C:\Perl\bin\perl.exe" _new.pl cell data 4 cell data 5 cell data 6 cell data 7 cell data 8 > Terminated with exit code 0.

I believe this gives you greater flexibility/adaptability and, for me, is quicker to write. :-)

Hope that helps