Closed Bug 1441079 Opened 6 years ago Closed 5 years ago

Allow to filter console by regular expression

Categories

(DevTools :: Console, enhancement, P3)

60 Branch
enhancement

Tracking

(firefox60 wontfix, firefox68 fixed)

RESOLVED FIXED
Firefox 68
Tracking Status
firefox60 --- wontfix
firefox68 --- fixed

People

(Reporter: sebo, Assigned: hemakshis)

References

(Blocks 2 open bugs)

Details

(Keywords: dev-doc-complete)

Attachments

(1 file)

The console filter should provide an option to filter by regular expressions. 

This could either be done by toggling an option, so the whole filter field is interpreted as regex, or by interpreting filter strings enclosed in slashes (e.g. /foo|bar/) as regexes.

The latter is probably the more future-proof solution, because it separates the regex from other filter strings allowing to enter multiple filters.
See Also: → 1291192
See Also: → 1441082
Blocks: 1441085
Product: Firefox → DevTools
Priority: -- → P3

Hi Nicolas,

I would like to take up this issue, could it be assigned to me?

Thanks
Hemakshi

Flags: needinfo?(nchevobbe)

Hello Hemakshi, thanks for wanting to help us and sorry for the delay.
I'm assigning you the bug.

The main function responsible for the text filtering is in devtools/client/webconsole/reducers/messages.js#794-825.

Let's try to do it as Sebastian pictured it: we should do a regex search if the filter text is of the following form /xyz/flags (we should make sure flags are valid, so we don't confuse this with a path search, e.g. /src/test)

Assignee: nobody → sachdev.hemakshi
Status: NEW → ASSIGNED
Flags: needinfo?(nchevobbe)

(In reply to Nicolas Chevobbe from comment #2)

Let's try to do it as Sebastian pictured it: we should do a regex search if the filter text is of the following form /xyz/flags (we should make sure flags are valid, so we don't confuse this with a path search, e.g. /src/test)

Good point about paths searches. It needs to be ensured that searching by path is still possible. And there might be cases where the entered string is a valid regular expression but is meant to be a path search, a simple example is /path/.

So the question is what to do in this case. Either do both, a normal text search and a regex search or somehow introduce an option to toggle regex search. Toggling might be implemented as a prefix regex: similar to the filters within the Network Monitor.

Sebastian

(In reply to Sebastian Zartner [:sebo] from comment #3)

(In reply to Nicolas Chevobbe from comment #2)

Let's try to do it as Sebastian pictured it: we should do a regex search if the filter text is of the following form /xyz/flags (we should make sure flags are valid, so we don't confuse this with a path search, e.g. /src/test)

Good point about paths searches. It needs to be ensured that searching by path is still possible. And there might be cases where the entered string is a valid regular expression but is meant to be a path search, a simple example is /path/.

In this case, both the strings matching the regex and the value "/path/" will be displayed. Suppose my file path looks like foo.bar/bug/123. If a user enters as /bug/ in the input then it will match this URL and show this message. As bug also seems to be a valid regular expression. I hope this is what Sebastian meant.

I tested this and it is working when implementing the method mentioned in comment #0 (i.e. by interpreting filter strings enclosed in slashes as regexes)

Flags: needinfo?(nchevobbe)

That isn't the case for all patterns though. For example, suppose the user searches for "/?path=/" hoping to search for the string "/?path=/", but since "?path=" isn't a a valid regex it doesn't work as expected.

Flags: needinfo?(nchevobbe)

The /path/ example was bad, because it matches in both cases, via a string and a regex search. Thayne gave a better example. So, /?path=/ should still match paths containing the string, even when the regex search fails in this case.

Sebastian

Any text enclosed between forward slashes is considered as a regex search. If the entered regex is invalid, a normal text search is performed.

Pushed by nchevobbe@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/906f52483d5b
Allow to filter console by regular expression. r=nchevobbe
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 68

I can't seem to find a regex search that provides results any different than a regular search. And all searches seem to be case insensitive. I need to be able to enter a regex string and get visibly different results than a standard search value. Can someone help me on this?

Flags: needinfo?(nchevobbe)

Hello Irene,

You can go to https://wary-soul.glitch.me/ , open the console, and filter with /(cool|rad)/

Flags: needinfo?(nchevobbe)

(In reply to Nicolas Chevobbe [:nchevobbe] from comment #11)

Hello Irene,

You can go to https://wary-soul.glitch.me/ , open the console, and filter with /(cool|rad)/

Tried that. It worked in Nightly but not in Dev edition.

After discussion on slack, I've solved the problem. Thanks again Nicolas!

Sorry, set this to dev-doc-complete by accident. I intended the edit for a different bug.

Added the following to the console page in the Filtering with Regular Expressions section:

You can also use a valid regular expression to filter the console output. For example, the following show video shows the results when filtering on two simple regular expressions: /(cool|rad)/ and /(cool)/.

{{EmbedYouTube("E6bGOe2fvW0")}}

Added:

You can filter content in the Web Console using regular expressions (bug 1441079).

Flags: needinfo?(nchevobbe)

Thanks Irene!

Flags: needinfo?(nchevobbe)

Won't it be a good idea to allow regex filtering for the netmonitor searches as well ?

It is a feature I miss from Chrome.

Won't it be a good idea to allow regex filtering for the netmonitor searches as well ?

That's tracked in bug 1575577.

Sebastian

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: