otto letter character
1221 123324 123431564
####
((\w)(?!\2)(\w)(?!\3|\2)(\w)(?!\4|\3|\2)(\w)\4\2(?!\5|\4|\3|\2)(\w)(?!\6|\5|\4|\3|\2)(\w)\5)
####
#!/usr/bin/perl
# match.pl
use strict;
my ($pat, $file) = @ARGV;
my $p;
{
my (%s, %i);
my $d = my $c = 1; # our regexp will be inside parens, so first backref is 2
$p = join (
"",
map {
if($s{$_}++){
"\\".$i{$_}
}
else{
$i{$_}=++$c;
$c>$d+1 ? '(?!'.join('|',map{"\\".abs}-$c+1..-$d-1).")(\\w)" : "(\\w)";
}
} split//,$pat
);
}
print '(',$p,")\n";
open my $fh, '<', $file;
my %s;
while (<$fh>) {
my @l = ();
while (/\b($p)\b/g) {
push @l, $1 unless $s{$1}++;
}
print join (", ",@l), $/ if @l;
}