in reply to Re^2: Regex help
in thread Regex help

abcdecgf

There are 6 unique letters, one is repeated at positions 3 and 6.

There must be 7! (No, not seven factorial...)

I don't know what the word is, so the letter "c" is only an example.

Are the positions fixed too? I'm assuming they are, since the problem is slightly more complex like that. Of course there are tons of ways to do it. And as shmem wrote, probably not best done with a single regex - although it may be possible, perhaps by means of one of those funky extensions still marked as "experimental". One possible way that springs to my mind is:

#!/usr/bin/perl use strict; use warnings; $_=<<'.'; bEjhMELGUaL smtMDEYSxyDvuQiUfAbJfYMPnfJAqaPnKL VWZWSdfYRSaSGlXOyPfxusC dtRAHabcdecgf taNdvtKdBlJcnFryVXObEDvawRyviWO hwlKiBpDWYeBPYhlpKFvrSeQ ksWmkXqQdLQPIzvKFE Jqrclq mPqQbMvkAx LtVuFMehKirSATuqlFzqwRknocsrcKXAE FNbOivdvkRonEkg apuPyHpTlssvVs BbwiHBvhfrSFwVkhwHkvoYjaGgntzFbEvPCIttD IAlYqoLUjtxsYvbwUBHIoMYmPJbGeXymuwERkHwSyKbE XMCcFgsYPzmJbVUsOwfDTgUiJ . while (/(?=([a-zA-Z]{8}))/g) { my @l = (my $found=$1) =~ /./g; print $found, "\n" if $l[2] eq $l[5] and do { my %h; @h{@l}=(); 7 == keys %h; } } __END__

Update: or, in a slightly more agile way:

for (/(?=([A-zA-Z]{8}))/g) { my @l=/./g; print $_, "\n" if $l[2] eq $l[5] and do { my %h; @h{@l}=(); 7 == keys %h; } }