in reply to Count the number of matched characters
This uses the (undocumented?) ()= "operator" to force m///g to return a list of matches, which then gets converted to a count in $count = ().$string_to_match='QWERTAAWAAAAKAAAAAAAA'; $check = substr($string_to_match, -17, 17); $count = () = ( $check =~ /(A)/g ); if ( $count >= 14) { print "correct"; }
-QM
--
Quantum Mechanics: The dreams stuff is made of
|
|---|