$s = "xxxxxxxxxxxxxxxxxxxx!"; if($s =~ /^\w{6,20}$/){print "it's a match";} else{print "no match";}