Sha256: 6eb45fc1d3a5d6734ae0f5ad94ce3b16209ebaba9b725b2cd728a83864e7e07f

Contents?: true

Size: 392 Bytes

Versions: 19

Compression:

Stored size: 392 Bytes

Contents

# -*- coding: utf-8 -*-
# simple_match.rbを、入力したパターンの
#前後10文字のみ表示するように変更

pattern = Regexp.new("(.{10})("+ARGV[0]+")(.{10})")
filename = ARGV[1]

count = 0

File.open(filename) do |file|
  file.each_line do |line|
    line.scan(pattern) do |s|
      puts "#{s[0]}<<#{s[1]}>>#{s[2]}"
      count += 1
    end
  end
end
puts "count: #{count}"

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
ruby_learner-1.2.9 contents/takahashi/sample_prog/final_check/simple_match2.rb
ruby_learner-1.2.8 contents/takahashi/sample_prog/final_check/simple_match2.rb
ruby_learner-1.2.7 contents/takahashi/sample_prog/final_check/simple_match2.rb
ruby_learner-1.2.6 contents/takahashi/sample_prog/final_check/simple_match2.rb
ruby_learner-1.2.5 contents/takahashi/sample_prog/final_check/simple_match2.rb
ruby_learner-1.2.4 contents/takahashi/sample_prog/final_check/simple_match2.rb
ruby_learner-1.2.3 contents/takahashi/sample_prog/final_check/simple_match2.rb
ruby_learner-1.2.2 contents/takahashi/sample_prog/final_check/simple_match2.rb
ruby_learner-1.2.1 contents/takahashi/sample_prog/final_check/simple_match2.rb
ruby_learner-1.2.0 contents/takahashi/sample_prog/final_check/simple_match2.rb
ruby_learner-1.1.15 takahashi/sample_prog/final_check/simple_match2.rb
ruby_learner-1.1.14 takahashi/sample_prog/final_check/simple_match2.rb
ruby_learner-1.1.13 takahashi/sample_prog/final_check/simple_match2.rb
ruby_learner-1.1.11 takahashi/sample_prog/final_check/simple_match2.rb
ruby_learner-1.1.10 takahashi/sample_prog/final_check/simple_match2.rb
ruby_learner-1.1.9 takahashi/sample_prog/final_check/simple_match2.rb
ruby_learner-1.1.8 takahashi/sample_prog/final_check/simple_match2.rb
ruby_learner-1.1.7 takahashi/sample_prog/final_check/simple_match2.rb
ruby_learner-1.1.6 takahashi/sample_prog/final_check/simple_match2.rb