As for most of these things, as text filter is the best solution. This:
#! /usr/bin/perl
use strict;
while (<>) {
print;
my @hits;
my @words = split /\b/, $_;
for (@words) {
push @hits, $_ if /a/i and /b/i and /c/i or /c.*c/i;
}
printf "• Found: %s\n", join ", ", @hits if @hits;
undef @hits;
}
will turn
The accountant sat in the back of the
cab wearing a black cocked hat
into
The accountant sat in the back of the
• Found: accountant, back
cab wearing a black cocked hat
• Found: cab, black, cocked
JD