in reply to Count the number of matched characters

You need to count the number of 'A'. Your code try to match 14..17 A without any other chars inbeetween.
$string_to_match='QWERTAAWAAAAKAAAAAAAA'; if ( substr($string_to_match, -17) =~ y/A// >= 14 ) { print 'Correct'; }
Boris