if($str2=~ m/^(abc|xyz)\w{6}|^\w{3}(abc|xyz)\w{3}|^\w{6}(abc|xyz)$/){ print "true "; }else{ print "false"; }