正则表达式截取字符串问题

八公山民 2009-08-12 11:01:54
string MatchException = Regex.Match(FileBlocks[i], @"\b(异常:)[\s\S]*").ToString();
string MatchExceptionMod = Regex.Replace(MatchException, @"[异常:]", "").ToString();

要截取的字符串如下:

异常:
Saaaaaaystem.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.DivideByZeroException: Attempted to divide by zero.
at ttt.MMTT.BLL.Logistics.Cus.Excep.GetValue(Int32 a, Int32 b)
at TTT.MMTT.BLL.Logistics.Cus.Excep.GetValue(Int32 a, Int32 b)

上面正则是取"异常"后面的字段存取到datatable,绑定到datagridview中,怎么才能去除异常后面的空行?因为导出到excel格式出现了问题.Saaaaaaystem.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.DivideByZeroException: Attempted to divide by zero.
at ttt.MMTT.BLL.Logistics.Cus.Excep.GetValue(Int32 a, Int32 b)
at TTT.MMTT.BLL.Logistics.Cus.Excep.GetValue(Int32 a, Int32 b) 上面这个字符串本来在第二行第5列,串到了 下下行的第一列。请高手从语法上分析怎么截取合适。

...全文
104 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
zl194 2009-08-13
  • 打赏
  • 举报
回复
太复杂了,看不懂.

110,571

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧