18

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
...

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

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

The regex has been tested at regexpal:

Regex tested at regexpal.com

But it has no effect in Chrome:

Chrome dev tools showing no effect from regex filtering

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?

Thanks.

Community
  • 1
  • 1
Peter W
  • 952
  • 8
  • 18
  • Does this answer your question? [Filter the Chrome console messages](https://stackoverflow.com/questions/44130085/filter-the-chrome-console-messages) – SuperStormer May 23 '23 at 05:37

3 Answers3

39

Since chrome 62 you can use negative filters in dev tools.

In the console filter box enter:

-<textToFilter> 

I.e: To remove entries with text "Animate" just type:

-Animate

More info:

https://developers.google.com/web/updates/2017/08/devtools-release-notes#negative-filters

user1990009
  • 855
  • 1
  • 7
  • 16
  • Thank you so much. I am getting bombarded with DEPRECATED warnings as one of my core frameworks has recently updated and changed its policy. Almost every single major library is affected. I can now focus on what's actually important. Thank you! – DanielK May 19 '20 at 15:31
2

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

^((?!Animate).)*$

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

Side Note:

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.

Community
  • 1
  • 1
Gideon Pyzer
  • 22,610
  • 7
  • 62
  • 68
  • I tried your answer filtering a different word in my logs on Chrome 68 and it worked. However according to regex101 it should not. Example: https://regex101.com/r/L7sgqb/1. I generally trust regex101. What's up with Chrome here (or is it regex101 that is incorrect...)? – Jason Kuhrt Sep 23 '18 at 16:24
  • Worth noting that Firefox supports something similar as of FF 73: " when you perform a text or regex search in the Console, you can negate a search item by prefixing it with ‘-’ (i.e. return results not including this term)." https://hacks.mozilla.org/2020/02/firefox-73-is-upon-us/ – Peter W Feb 13 '20 at 00:36
1

You need to use :

 ^(?!.*?Animate) 
Nigrimmist
  • 10,289
  • 4
  • 52
  • 53