require 'stringio'

f = StringIO.new(<<ENDOFSTRING)
xe-0/0/2.0      up    up   aenet    --> ae1.0
xe-0/0/3        up    up
xe-0/0/3.0      up    up   aenet    --> ae1.0

xe-10/0/6.0     up    down aenet    --> ae40.0
xe-24/0/3.0     up    down aenet    --> ae30.0
ENDOFSTRING

target_column = 6

results = ""

f.each do |line|
  md = line.match(/
        up
        \s*
        down
        \s*
        aenet
        .*?
        -->
        \s*
        (.*)
        \n
        \z
  /xms)

  if md
    results << $1 << " "
  end
end

p results.rstrip


--output:--
"ae40.0 ae30.0"

-- 
Posted via http://www.ruby-forum.com/.