Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filter by regex example

Could anyone provide an example of a regex filter for the Google Chrome Developer toolbar?

I especially need exclusion. I've tried many regexes, but somehow they don't seem to work:

enter image description here

like image 937
kraftwer1 Avatar asked Oct 02 '14 10:10

kraftwer1


People also ask

What is a regex filter?

The Regex Filter transform filters messages in the data stream according to a regular expression (regex) pattern, which you can define. You also define the Regex Filter to either accept or deny incoming messages based on the regular expression.

Can I use regex filter Gmail?

You can set up Content compliance settings using regular expressions. Regular expressions are also useful for other advanced Gmail settings, such as routing settings. A regular expression, also called a regex, is a method for matching text with patterns.

Can you use wildcard in regex?

In regular expressions, the period ( . , also called "dot") is the wildcard pattern which matches any single character. Combined with the asterisk operator . * it will match any number of any characters.


2 Answers

It turned out that Google Chrome actually didn't support this until early 2015, see Google Code issue. With newer versions it works great, for example excluding everything that contains banners:

/^(?!.*?banners)/ 
like image 110
kraftwer1 Avatar answered Nov 09 '22 20:11

kraftwer1


It's possible -- at least in Chrome 58 Dev. You just need to wrap your regex with forward-slashes: /my-regex-string/

For example, this is one I'm currently using: /^(.(?!fallback font))+$/

It successfully filters out any messages that contain the substring "fallback font".

EDIT

Something else to note is that if you want to use the ^ (caret) symbol to search from the start of the log message, you have to first match the "fileName.js?someUrlParam:lineNumber " part of the string.

That is to say, the regex is matching against not just the log message, but also the stack-entry for the line which made the log.

So this is the regex I use to match all log messages where the actual message starts with "Dog":

/^.+?:[0-9]+ Dog/ 
like image 33
Venryx Avatar answered Nov 09 '22 22:11

Venryx