【发布时间】:2015-08-18 18:53:21
【问题描述】:
我有一个多行字符串,如下所示:
2012-15-08 07:04 Bla bla bla blup
2012-15-08 07:05 *** Error importing row no. 5: The import of this line failed because bla bla
2012-15-08 07:05 Another text that I don't want to search...
2012-15-08 07:06 Another text that I don't want to search...
2012-15-08 07:06 *** Error importing row no. 5: The import of this line failed because bla bla
2012-15-08 07:07 Import has finished bla bla
我想要的是在 RegularExpression(使用 PowerShell)的帮助下提取所有有错误的行号。所以我需要找到“*** Error importing row no.”和下面的“:”之间的数字,因为这总是会给我行号。
我查看了其他各种 RegEx 问题,但老实说,答案对我来说就像中文。
尝试在 http://regexr.com/ 的帮助下构建 RegEx,但到目前为止还没有成功,例如使用以下模式:
"Error importing row no. "(.?)":"
有什么提示吗?
【问题讨论】:
-
@AvinashRaj 谢谢,但这不起作用
标签: regex string powershell string-matching powershell-4.0