リンク集

#! ruby -Ks
 
require 'kconv'
 
newline = ""
date = ""
title = ""
flag = true
counter = 0
ifile = "001 基本の虫食い算(1).txt"
File::open( ifile ) {|f|
	f.each { |line|
		line.sub!(//, "…")
		flag = !flag if /-<cut/ =~ line
		if /◇◆◇━/ =~ line
			counter += 1
			next
		end
		if /^[  ]+(20\d\d\/\d\d\/\d\d).+$/ =~ line
			date = $1
			title = line.sub!(/^[  ]+/, "").chop! + " - " + ifile
			newline << title.kconv(Kconv::UTF8, Kconv::SJIS) + "\n"
			next
		end
		if /^【.+/ =~ line && flag
			line = line.kconv(Kconv::UTF8, Kconv::SJIS)
			newline << "===== " + line.chop! + " =====" + "\n"
			next
		end
		line = "  " + line
		line = line.kconv(Kconv::UTF8, Kconv::SJIS)
		newline << line if counter == 2
	}
}
 
ofile = "result/" + date.gsub(/\//, "_") + ".txt"
 
out = File.open( ofile, 'w')
out.puts newline
out.close
 
__END__
 
number = 0
 
Dir::glob("0*.txt").each {|f|
	number += 1
 
	puts f + sprintf("%03d", number) + ".txt"
 
}
 
exit
playground.txt · 最終更新: 2019/04/11 10:53 (外部編集)
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0