Sha256: bb59b81e2165b1497bbb9524787acf84070699939928b465e2b1696515c049f1
Contents?: true
Size: 419 Bytes
Versions: 19
Compression:
Stored size: 419 Bytes
Contents
# -*- coding: utf-8 -*- #simple_match2.rbの #前後10文字の中にあるパターンをカウントしない不具合を解消 pattern = Regexp.new(ARGV[0]) filename = ARGV[1] count = 0 File.open(filename) do |file| file.each_line do |line| line.scan(pattern) do |s| pre = $` post = $' puts "#{pre[-10,10]}<<#{s}>>#{post[0,10]}" count += 1 end end end puts "count: #{count}"
Version data entries
19 entries across 19 versions & 1 rubygems