Created
March 1, 2013 22:05
-
-
Save thinkAmi/5068282 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
# RubyでFromTo表現のテキストファイルを、カウントアップ表現に変換する | |
# 使い方 | |
# convert.rb 変換前のファイルパス > 変換後のファイルパス | |
export_count = 0; | |
while line = gets | |
line.lstrip! | |
if line =~ /^([a-z]|[A-Z])?[0-9]{1,4}.([a-z]|[A-Z])?[0-9]{1,4}/ | |
results = line.scan(/[0-9]{1,4}/) | |
first = results[0] | |
last = results[-1] | |
first.to_i.step(last.to_i, 1) { |n| | |
formatted = format("%04d", n) | |
puts "x" + formatted + "x" | |
export_count += 1 | |
} | |
end | |
end | |
puts export_count.to_s + "件" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Blog記事はこちら
http://d.hatena.ne.jp/thinkAmi/20130302/1362175793