04/06/11 01:29
// $shell dat2chregex.exe 1086143976.dat
// csc dat2chregex.cs
//2ch dat から リンクを抜き出すプログラム
//C♯の正規表現むずい。もっとなんとかならん?>>1
using System;
using System.Text.RegularExpressions;
using System.IO;
class Grep {
static void Main(string[] args) {
TextReader reader = null;
reader = new StreamReader(
args[0], System.Text.Encoding.GetEncoding(932));
if (reader != null) {
Regex regex = new Regex("ttp");
Regex fase4 = new Regex(@"<br>");
Regex fase3 = new Regex(@"(?<TTP>h?t?URLリンク([^\s]*))\s*");
string line;
string [] sta;
int i;
while ((line = reader.ReadLine()) != null) {
sta = fase4.Split(line);
for(i=0;i<=sta.Length-1;i++){
Match m=fase3.Match(sta[i]);
if (m.Success) {
Console.WriteLine(fase3.Match(sta[i]).Result("${TTP}"));
}} }
reader.Close();
}
}
}