in reply to Regex matching on grid alignment
If you set $/ to a reference to the number of (virtual) grid columns, then open a filehandle to a reference to your string, you can then read each (virtual) grid row as a separate record and perform your matching on each distinct row-record.
$ perl -Mstrict -Mwarnings -Mautodie -le ' sub match_virtual_grid_rows { local $/ = \shift; open my $fh, "<", \shift; grep { /(.)\1\1/ } <$fh>; } my $virtual_grid_columns = 5; my $grid_string = "ABCBBBCBADBCCACDDDAC"; print for match_virtual_grid_rows($virtual_grid_columns, $grid_str +ing); ' DDDAC
A couple of additional tests:
-- Ken
|
|---|