regexps = [ /^digi .*nyo[^a-zA-Z0-9]{0,3}$/, /^petit .*nyu[^a-zA-Z0-9]{0,3}$/, /^rabi .*[a-zA-Z0-9].*$/, /^gema .*igema[^a-zA-Z0-9]{0,3}$/, /^piyo .*pyo[^a-zA-Z0-9]{0,3}$/ ] while s = gets s.strip! # p s if ![ "digi", "petit", "rabi", "gema", "piyo" ].include?( s.split[0] ) p "TEST" puts "WRONG!" next end s.downcase! cnt = 0 regexps.each do |reg| if s =~ reg cnt += 1 end end puts ( cnt == 1 ? "CORRECT (maybe)" : "WRONG!" ) end