问题
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:
But it has no effect in Chrome:
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.
回答1:
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.
回答2:
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
回答3:
You need to use :
^(?!.*?Animate)
来源:https://stackoverflow.com/questions/38823920/is-it-possible-to-filter-chrome-console-log-using-a-negated-text