I don't think this should be used, but here goes:
sub inclusive {
my ($big, $little) = @_;
$big =~ join(
'',
map { "(?=.*" . join('.*', @$_) . ")" }
map { ++$i & 1 ? [ map quotemeta, split // ] : () }
join('', sort split //, $little) =~ /((.)\2*)/gs;
);
}
It feels like a hack...
Update: and here's another hack:
sub inclusive {
($chunk, $word) = @_; # sorry, no 'my' here
my $r;
$r = qr{
(??{ "[^\Q$word\E]*" })
((??{ "[\Q$word\E]" }))
(?{ substr($word, index($word,$1), 1) = "" })
(?(?{ length $word })(??{ $r }))
|
(?!)
}x;
scalar $chunk =~ $r;
}
_____________________________________________________
Jeff[japhy]Pinyan:
Perl,
regex,
and perl
hacker.
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??; |