use strict; use warnings; my $stuff1 = qr/[^A]|[^C-Z]*/; my $stuff2 = qr/[^A-B]|[^D-Z]*/; my $stuff3 = qr/[^A-C]|[^E-Z]*/; my $regex = qr{ A $stuff1 B $stuff2 C $stuff2 D }x; while (my $line = ) { chomp($line); if ($line =~ $regex) { print "Matched: \" $line \"\n"; } else { print "**Did NOT match \"$line\"\n"; } } __DATA__ ABhere is intervening textC D A B C, lots of text and numbers and equals and slashes DEFG ABhere IS intervening TEXTC D A BIG foo is B intervening text CD A Big Cat interjects itself into text before CD