$string = "f4\%"; if($string !~ /^\d{1,3}\%$|^\d+$/){ print "Ungueltig!"; }