27

Is it possible to search with regular expressions within Google Chrome's developer console? I know how to search for text within the console (Ctrl+F), but can't see any way to enable regular expressions.

Do there e.g. exist extensions to enable this, if not supported by Chrome itself?

Update

I have created a feature request for regular expression support in developer console search, since there appears to be no current support for it.

Community
  • 1
  • 1
aknuds1
  • 65,625
  • 67
  • 195
  • 317

2 Answers2

8

Ctrl + F search with regular expressions does not exist. This functionality requires tight integration in the context of the developer tools, so if you don't like the alternative below, you have to look through the developer tools' source code, find the part that is responsible for implementing Ctrl+F, write a patch and apply the patch using https://stackoverflow.com/a/17044405/938089.

Click on the funnel icon and tick the Regex checkbox. Then you can filter console messages to only show messages that match your (case-insensitive) (JavaScript) regular expression.

Rob W
  • 341,306
  • 83
  • 791
  • 678
  • 1
    I don't think the filter/funnel works with multiline regexes unfortunately. – aknuds1 Sep 28 '14 at 09:10
  • Would you happen to know where to file a suggestion to implement console regex search in Chromium? – aknuds1 Sep 28 '14 at 09:20
  • @aknuds1 Lack of multi-line regexes is not a real issue. Just use `(^|\n)` instead of `^` and `(\n|$)` instead of `$`. The regex applies to individual messages only though, so if you use `console.log(1);console.log(2)`, then you cannot use `0\n1` to find these two messages. – Rob W Sep 28 '14 at 11:56
  • @aknuds1 If you want to file a suggestion, just file a request at https://crbug.com/new. Add a link to the issue after you've filed the issue, other readers may be interested in starring the issue. – Rob W Sep 28 '14 at 11:57
  • Thanks. Well yeah, what I'm searching for spans several log messages, so the filter isn't going to do me much good. – aknuds1 Sep 28 '14 at 12:27
  • @aknuds1 Here is a trick: Use the OR token to create a search that spans multiple lines. You will get more than usual, but it is better than having to dig through hundreds of lines by hand. To continue with my last example, it would look like `(^|\n)(0|1)($|\n)`. – Rob W Sep 28 '14 at 12:29
  • I created an [issue](https://code.google.com/p/chromium/issues/detail?id=418406). – aknuds1 Sep 28 '14 at 12:36
  • 1
    @aknuds1 If you want to get the feature as soon as possible, you can also contribute to the Developer tools yourself. See https://developer.chrome.com/devtools/docs/contributing if you are interested. – Rob W Sep 28 '14 at 12:42
  • Thanks for the suggestion, I'll consider it at the very least :) – aknuds1 Sep 28 '14 at 12:43
4

Some chrome extension could support(at least partly) your requirement.

For example: "Chrome Regex Search" developed by rshen. It looks like this: enter image description here

To install it:

  1. Access Chrome Web Store
  2. Search the keyword "regex"
  3. Click "ADD TO CHROME" button close to "Chrome Regex Search"
bearzyj
  • 1,521
  • 1
  • 9
  • 10