using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Text.RegularExpressions;
namespace _2chBrowser
{
class ResInfo
{
public string Name { get; set; }
public string Mail { get; set; }
public string Date { get; set; }
public string Id { get; set; }
public string BeId { get; set; }
public string Text { get; set; }
public ResInfo(string name, string mail, string date, string id, string beid, string text)
{
this.Name = name;
this.Mail = mail;
this.Date = date;
this.Id = id;
this.BeId = beid;
this.Text = text;
}
public static List<ResInfo> CreateList(string sureAllText)
{
const string Ptn = @"^(?<name>[^<]+)<>(?<mail>[^<]*)<>(?<date>.*) ID:(?<id>[^<]*)<>(?<text>.*)$";
List<ResInfo> list = new List<ResInfo>();
TextReader tr = (new StringReader(sureAllText));
while (0 < tr.Peek())
{
string s = tr.ReadLine();
var mch = Regex.Match(s, Ptn);
if (mch.Success)
{
string name = mch.Groups["name"].Value;
string mail = mch.Groups["mail"].Value;
string date = mch.Groups["date"].Value;
string id = mch.Groups["id"].Value;
string text = mch.Groups["text"].Value;
var item = new ResInfo(name, mail, date, id, "", text);
list.Add(item);
}
}
return list;
}
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uQ29sbGVjdGlvbnMuR2VuZXJpYzsKdXNpbmcgU3lzdGVtLkxpbnE7CnVzaW5nIFN5c3RlbS5UZXh0Owp1c2luZyBTeXN0ZW0uSU87CnVzaW5nIFN5c3RlbS5UZXh0LlJlZ3VsYXJFeHByZXNzaW9uczsKCm5hbWVzcGFjZSBfMmNoQnJvd3Nlcgp7CiAgICBjbGFzcyBSZXNJbmZvCiAgICB7CiAgICAgICAgcHVibGljIHN0cmluZyBOYW1lIHsgZ2V0OyBzZXQ7IH0KICAgICAgICBwdWJsaWMgc3RyaW5nIE1haWwgeyBnZXQ7IHNldDsgfQogICAgICAgIHB1YmxpYyBzdHJpbmcgRGF0ZSB7IGdldDsgc2V0OyB9CiAgICAgICAgcHVibGljIHN0cmluZyBJZCB7IGdldDsgc2V0OyB9CiAgICAgICAgcHVibGljIH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gICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIHN0cmluZyBuYW1lID0gbWNoLkdyb3Vwc1sibmFtZSJdLlZhbHVlOwogICAgICAgICAgICAgICAgICAgIHN0cmluZyBtYWlsID0gbWNoLkdyb3Vwc1sibWFpbCJdLlZhbHVlOwogICAgICAgICAgICAgICAgICAgIHN0cmluZyBkYXRlID0gbWNoLkdyb3Vwc1siZGF0ZSJdLlZhbHVlOwogICAgICAgICAgICAgICAgICAgIHN0cmluZyBpZCA9IG1jaC5Hcm91cHNbImlkIl0uVmFsdWU7CiAgICAgICAgICAgICAgICAgICAgc3RyaW5nIHRleHQgPSBtY2guR3JvdXBzWyJ0ZXh0Il0uVmFsdWU7CiAgICAgICAgICAgICAgICAgICAgdmFyIGl0ZW0gPSBuZXcgUmVzSW5mbyhuYW1lLCBtYWlsLCBkYXRlLCBpZCwgIiIsIHRleHQpOwogICAgICAgICAgICAgICAgICAgIGxpc3QuQWRkKGl0ZW0pOwogICAgICAgICAgICAgICAgfQoKICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4gbGlzdDsKICAgICAgICB9CiAgICB9Cn0K