#!/usr/koeki/bin/ruby # coding: euc-jp STDERR.print "検索パターン : " pattern = STDIN.gets.chomp request = Regexp.new(pattern, true, "e") open("station.dat","r") do |candidate| while station = candidate.gets if request =~ station # print station if /(\S+)\s+(\S+)\s+(\S+)\s+(\S+)/ =~ station printf("%s駅\n", $1) end end end end