in reply to Regex Help : Group in Strings

Update: Made a correction and added a variation.

#! perl -slw use strict; my $re = qr[ (.) (?=(.)(.)) (?= .* (?: \1\2\3 | \1\3\2 | \2\1\3 | \2\3\1 | \3\1\2 | \3\2\1 ) .* $) ]x; while( <DATA> ) { chomp; print "'$_'", $_ !~ m[$re]g ? ' passed' : 'failed'; } __DATA__ abcdbca abcba abcdabe

Ouput

P:\test>test3 'abcdbca'failed 'abcba'failed 'abcdabe' passed

A variation

my $re = qr[ (.) (?=(.)(.)) (?= .* (?: \1 (?: \2\3 | \3\2 ) | \2 (?: \1\3 | \3\1 ) | \3 (?: \1\2 | \2\1 ) ) .* $) ]x;

Examine what is said, not who speaks.
Silence betokens consent.
Love the truth but pardon error.