1
2
3
4
5
6
months = { "January" => 1, "February" => 2, "March" => 3 }

File.open('yourfile.txt').each_line do |line|
  result = months[line[/(#{months.keys.join("|")})/i]]
  puts result if result
end