【发布时间】:2014-03-02 08:32:57
【问题描述】:
我有一个类型的字符串
2014-02-19 16:21:46,139 错误 queue.TaskQueueEngine - 未能 解决一级故障检测任务的任务队列入口 java.sql.SQLException: 网络错误 IOException: Connection timed 出:连接 2014-02-19 16:35:48,247 错误 [pool-1-thread-1] cluster.ClusterServiceImpl - 尝试更新时出现意外错误 LastCheckinTime java.sql.SQLException: 网络错误 IOException: 连接超时:连接
....
我正在尝试按日期时间值将其拆分为子字符串,例如。
log[0]=2014-02-19 16:21:46,139 错误 queue.TaskQueueEngine - 失败 解决一级故障检测任务的任务队列入口 java.sql.SQLException: 网络错误 IOException: Connection timed 出:连接
log[1]=2014-02-19 16:35:48,247 错误 [pool-1-thread-1] cluster.ClusterServiceImpl - 尝试更新时出现意外错误 LastCheckinTime java.sql.SQLException: 网络错误 IOException: 连接超时:连接
我正在使用以下命令
string exLogs = System.IO.File.ReadAllText(@"D:\orion.log");
string[] messages = Regex.Split(exLogs,] @"^([0-9]{4})-([0-1][0-9])-
([0-3][0-9])\s([0-1][0-9]|[2][0-3]):([0-5][0-9]):([0-5][0-9])");
但是它不是给我子字符串而是给我
log[0]=2014
log[1]=02
等等。 我可能做错了什么。 感谢任何帮助将不胜感激。
【问题讨论】:
-
-
@SudhakarTillapudi - 假定日期之后的错误日志文本从不包含逗号。我会非常厌倦假设。
标签: c# regex pattern-matching