╰─ ./sys.rb k is '1' k is '[1, :ios]' ╭─ ytti@lintukoto ~/tmp 10:33:01 ╰─ cat sys.rb #!/usr/bin/env ruby require "pry" msg1 = "jotain cisco heippa hei" msg2 = "aivan muuta juniper joooko" msg3 = "arbua testiä myös" conds = { ios: /cisco/, jnpr: "juniper", aruba: /aruba/, } msg = msg1 k = msg.split.find_index do |e| e.match conds[:ios] end puts "k is '#{k}'" k = conds.each do |key, value| if index=msg.split.find_index { |e| e.match value } break [index, key] end end puts "k is '#{k}'" ╭─ ytti@lintukoto ~/tmp 10:33:05 ╰─