Thanks to ikegami (!), aquarium & dasgar for politely pointing me in the right direction. Thank you ww (assuming, that is, it is not some automatically generated reply which is triggered by the pattern /how should i/ig ) for warning me from the undesirable consequences my message may inflict (the worst of all is the re-reading the "how to pose a question" tutorial).
though not a one liner the following is simple to understand and does the trick
$_='nor neither nor';
my $cnt = 0;
while ((/(.*?)nor/ig) ) { # =================== coarse match
printf ("\n");
printf (STDOUT qq/\$\`:%s\n/,$`);
printf (STDOUT qq/\$\&:%s\n/,$&);
printf (STDOUT qq/\$\':%s\n/,$');
if ($1 !~ /\bneither\b/i){ # =========== finer match
printf ("match no. %d: ",$cnt++);
printf ("matched ok\n");
}
else {
printf ("match no. %d: ",$cnt++);
printf ("no match\n");
};
}
|