#!/usr/bin/env ruby

messages = [
  "jotain cisco heippa hei",
  "aivan muuta juniper joooko",
  "arbua testiä myös",
]

conds = {
  ios: /cisco/,
  jnpr: "juniper",
  aruba: /aruba/,
}

messages_parsed = messages.map do |message|
  solution = conds.reduce(nil) do |_, (_type, matcher)|
    found_index = message.index(matcher)
    break [matcher, message[found_index..-1]] if found_index
  end

  solution || [nil, nil]
end
 
puts messages_parsed