use strict; use warnings; my ($first, $last) = $find =~ /([A-Z])[A-Z]*([A-Z])/; #extract first and last character if ($string =~ /$first/ && $string =~ /$last/) #check both character present in string { my $out; for ($first..$last) #increment inbetween characters { $out = $out.$_ ; } print "'$find' string found" if ($string =~ /$out/); # if found print the string }