in reply to Re^2: Nonrepeating characters in an RE (updated)
in thread Nonrepeating characters in an RE

> OP > For example, my "template" might look like this: "abcdefa" and I already have the code that generates (.)?????\1. I can't figure how to make the "?"s say "these guys all have to be distinct".

> But I believe your example is also for "all distinct letters", it isn't clear to me how you'd use it for BernieC's templates.

OK taking under assumption, that what the OP meant was to only match strings build from a "template" with an anchored substring having the constraint of (certain?) unique letters, one can easily adapt the above regex solution.

use v5.12; use warnings; use Data::Dump; #ddx my @words = map { "..X${_}X.." } <{a,b,c,d}{a,b,c,d}{a,b,c,d}>; my $class = "[abc]"; #$class = '.'; #uncomment to match d too my $len = 3; for (@words) { say "$_" if $_ =~ / X # start anchor ( ($class) (?! .{0,$len} \g{-1} # relative backreference .*? X ) ){$len} X # end anchor /x; }

..XabcX.. ..XacbX.. ..XbacX.. ..XbcaX.. ..XcabX.. ..XcbaX..

Hope that's clearer now. :)

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

update

added part

.*? X # end anchor

update

replaced .*? with .{0,$len}

NB: technically $len-1 would be better, but the end anchor makes this redundant

update

OK I agree that this is a mess. But I'd rather wait for clarifiation from the OP before suggesting better solutions.