#!/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 = msg.split.find_index.with_object(conds) do |e, conds| conds.any? { |key,value| e.match value } end puts "k is '#{k}'"