$pattern = LP[SKTAQEHLDN][TA][GN][EDASTV] = 5/6 #### #!/usr/bin/perl -wl use strict; while (my $string = ) { chomp($string); my @matches = $string =~ /(L)?(P)?([SKTAQEHLDN])?([TA])?([GN])?([EDASTV])?/; my $num_matches; for (@matches) { $num_matches++ if defined($_); } if ($num_matches > 4) { print "$string matches ($num_matches/6)"; } else { print "$string does not match ($num_matches/6)"; } } __DATA__ LPSTEOPRTRYERTRETR HELLO WORLD PERL MONKS #### LPSTEOPRTRYERTRETR matches (5/6) HELLO WORLD does not match (2/6) PERL MONKS does not match (2/6)