正则表达式匹配某些行,除非它们包含某些单词(可用的正则表达式词汇有限)
我正在使用一个日志尾随应用程序(BareTailPro),它突出显示与正则表达式匹配的行。我当前将过滤器设置为仅 error
(忽略大小写),它会返回,例如:
25/07/2011 00:09:43.384 [Error] Timeout elapsed
25/07/2011 01:44:04.541 [Error] Receiver TopicName message count changed
25/07/2011 06:07:23.648 [Error] Error processing files
25/07/2011 09:40:04.591 [Error] Receiver TopicName message count changed
25/07/2011 16:42:12.163 [Error] Error Getting Matches & Rejects
我不想看到带有 Receiver TopicName.*
的行。
是否可以设置正则表达式来执行此操作?该应用程序的表达词汇量似乎极其有限:参考
I'm using a log tailing app (BareTailPro) that highlights rows which match regular expressions. I currently have the filter set to just error
(ignore case on) which returns, for example:
25/07/2011 00:09:43.384 [Error] Timeout elapsed
25/07/2011 01:44:04.541 [Error] Receiver TopicName message count changed
25/07/2011 06:07:23.648 [Error] Error processing files
25/07/2011 09:40:04.591 [Error] Receiver TopicName message count changed
25/07/2011 16:42:12.163 [Error] Error Getting Matches & Rejects
I don't want to see the rows with Receiver TopicName.*
.
Is it possible to set up a regex to do this? The app seems to have an extremely limited expression vocabulary: reference
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
鉴于 Dogbert 的回答说没有负面的前瞻,我建议这样做:
如果您知道错误之后发生的所有可能的事情是什么,例如
Timeout
、Error
、获取匹配时出错
等...您可以将所有这些添加到您的正则表达式中。因此,您可以匹配error (Timeout|Error|Error Getting Matches)
等,而不是匹配错误。这不是一个完美的解决方案(并且您可能会面临错过一些解决方案的风险),但它可以工作。
Given Dogbert's answer which says there's no negative lookahead I suggest this:
If you know what all the possible things that come after error are, for example
Timeout
,Error
,Error Getting Matches
, etc... You could add all of that to your regexp. So instead of matching error, you could matcherror (Timeout|Error|Error Getting Matches)
and so on.It is not a perfect solution (and you run the risk of missing some), but it could work.
这是不可能的,因为该页面上没有提到前瞻语句支持。
It's not possible as there's no look ahead statement support mentioned on that page.
如果 BareTailPro 支持,您可以尝试负向预测。
You can try a negative lookahead if BareTailPro supports it.