111,120
社区成员
发帖
与我相关
我的任务
分享foreach(string s in richTextBox1.Lines)
{
if (s.IndexOf("report")>0)
richTextBox2.Text += s.Remove(s.LastIndexOf(":")) + "\r\n";
}
string str = @"2010-01-01 01:01:01:5158=report
2010-01-01 01:03:03:5159=result
2010-01-01 01:08:08:5160=message
2010-01-01 01:11:11:5161=report
2010-01-01 01:12:12:5162=report
2010-01-01 01:13:13:5163=message
2010-01-01 01:16:16:5164=report
2010-01-01 01:18:18:5165=result";
StringBuilder sb = new StringBuilder();
MatchCollection mc = Regex.Matches(str, ".*");
foreach (Match m in mc)
{
string temp = m.Value;
if (temp != "")
sb.Append(temp.Substring(0, temp.LastIndexOf(":")));
}
结果:
2010-01-01 01:01:01
2010-01-01 01:11:11
2010-01-01 01:12:12
2010-01-01 01:16:16
。。。。