是否可以使用否定的文字过滤Chrome控制台日志? [英] Is it possible to filter Chrome console log using a negated text?

查看:136
本文介绍了是否可以使用否定的文字过滤Chrome控制台日志?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给出控制台日志输出,例如:

Given console log output such as:

...
app.js:4408 update w/ model.location: Discovering
app.js:4408 update w/ action: Animate 911583 { width = 320, height = 480 }
app.js:4408 update w/ model.location: Discovering
app.js:4408 update w/ action: Animate 911609 { width = 320, height = 480 }
app.js:4922 some other log message
app.js:1923 yet another thing on the console
...

是否可以让Chrome删除包含"Animate"一词的所有行?

Is it possible to get Chrome to remove all lines that include the word "Animate"?

我尝试使用负向超前,例如:.*(?!Animate).*(另请参见:如何在Chrome中对正则表达式中的特定词求反?没运气.

I've tried using a negative lookahead like: .*(?!Animate).* (see also: How to negate specific word in regex?) in Chrome, with no luck.

正则表达式已在 regexpal 中进行了测试:

The regex has been tested at regexpal:

但是它在Chrome中无效:

But it has no effect in Chrome:

能够只输入!Animate"或"Animate" [x]否定过滤器会很棒.有可能吗,或者有人可以在这种情况下使用否定的正则表达式来工作吗?

Being able to just type "!Animate" or "Animate" [x] negate filter would be great. Is that possible, or can anyone get a negate regex to work in this situation?

谢谢.

推荐答案

您可以使用它来过滤出在主字符串中任意位置包含Animate字符串的任何结果:

You can use this to filter out any result that contains the Animate string at any point in main string:

^((?!Animate).)*$

说明:

  • ^-字符串开头
  • (?!Animate)-负前行(在此光标处,不匹配下一位,无需捕获)
  • .-匹配任何字符(换行符除外)
  • ()*-先前组中的0个或更多
  • $-字符串结尾
  • Explanation:

    • ^ - Start of string
    • (?!Animate) - Negative lookahead (at this cursor, do not match the next bit, without capturing)
    • . - Match any character (except line breaks)
    • ()* - 0 or more of the preceding group
    • $ - End of string
    • 网络"面板中的负向超前功能目前已中断,但在控制台"面板中可以正常运行.我在回答修复,等待审核.

      Negative lookahead is currently broken in the Network panel, but fine in the Console panel. I discovered the issue when I was answering this question recently. I pushed a fix, awaiting review.

      这篇关于是否可以使用否定的文字过滤Chrome控制台日志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆