Sha256: 01ab9dfbddee432e594e28c6e0956bb6357230e678286fb3ea9f78890feb245c
Contents?: true
Size: 380 Bytes
Versions: 19
Compression:
Stored size: 380 Bytes
Contents
# -*- coding: utf-8 -*- # 前後の字数を変更できるように pattern = Regexp.new(ARGV[0]) filename = ARGV[1] len = ARGV[2].to_i count = 0 File.open(filename) do |file| file.each_line do |line| line.scan(pattern) do |s| pre = $` post = $' puts "#{pre[-len, len]}<<#{s}>>#{post[0, len]}" count += 1 end end end puts "count: #{count}"
Version data entries
19 entries across 19 versions & 1 rubygems