How to run a regex search on Google Chrome or Firefox?

44

6

How can I search for expressions like 'foo|bar' on webpages using browsers like Google Chrome or Firefox?

719016

Posted 2012-02-03T01:55:11.050

Reputation: 2 899

Answers

24

For Google Chrome, you could install one of the following extensions:

  1. Regular Expression Searcher

    • To open the extension, press /.

    • To start searching, press Enter.

    • To jump to the next match, press N.

    • To jump to the previous match, press Shift + N.

  2. Regex Search

    • To open the extension, press Alt + Shift + F.

    • To start searching, press Enter.

    • To jump to the next match, click Next.

    • To jump to the previous match, click Prev.

After installing the extension, restart your browser. When testing the extension, note that extension are disabled by default on Chrome's "special" pages, such as New Tab or the Chrome Webstore.

Dennis

Posted 2012-02-03T01:55:11.050

Reputation: 42 934

2

Another extension in the Chrome Web Store is Regex Search. It is more highly rated than the other two, and it works for me.

– mernst – 2014-10-25T16:56:17.253

@mernst: I've replaced my second suggestion (which is horribly broken in the latest Chrome) with yours. If you could jump to the next match without using the mouse, it would be perfect. – Dennis – 2014-10-25T17:15:40.910

Regex Search is open source which I feel important in any extension that gets full access to all pages I browse. Can now jump by Enter/Shift+Enter.

– Beni Cherniavsky-Paskin – 2015-11-05T10:59:21.667

3I tried both these and neither worked. – Jason – 2012-10-03T17:07:32.473

Regular Expression Search works better for me, Regular Expression Searcher breaking the html code (specially in <pre> text) – kenorb – 2013-03-13T11:57:10.613

9

Another option is VIMIUM.

The point of this Chrome plugin is to get Vim navigation to your Chrome pages, so you can use keys like J and K to scroll down the page.

However, since it is vi-based, it has regular expression support so does VIMIUM.

Much like Vim, while looking at the page, type "/<regexp>, and it will start searching the page... I don't use it often (I use Ctrl + F much more), but when I need it, it is there and works.

To work with regexp while searching you need to turn it on in the plugin advanced options.

Frank Merrow

Posted 2012-02-03T01:55:11.050

Reputation: 252

-1: Doesn't do regex search, which is what OP asked for... – mgalgs – 2013-05-14T20:37:38.857

1Yeah it does by "/" and your RegExp – Frank Merrow – 2013-05-15T22:22:07.913

7Oh, looks you have to enable an option in the Vimium Advanced Options to turn on regex searching. Quite useful! Will upvote if you edit your answer to include mention of the fact that you have to enable it in the Vimium options. – mgalgs – 2013-05-16T00:25:13.697

4

Firefox

I recently went looking for this very feature as I got tired of searching for a word and having to go through all the instances where the word I'm looking for is a sub-string of a larger word.

Regex Find is a nice lightweight extension which enhances the standard Firefox Find Bar by adding an option to treat the search term as a regular expression. It seems to be Open Source as it source code is available on GitHub.

I also like it because it works well with VimFx.

Anthony Geoghegan

Posted 2012-02-03T01:55:11.050

Reputation: 3 095

2

Here's a bookmarklet that'll highlight regular expression searches. It doesn't have incremental search like the native find box, but it does the job. Each new search is highlighted in a different color.

user

Posted 2012-02-03T01:55:11.050

Reputation: 949

1

This commandline-centric answer may not be well-received, but for what it's worth, whenever I need to do this, I just view the source, save it as a text file, and use grep -E or grep -oE on it.

Better yet, if it is a page directly accessible without much login hassle or whatnot, just curl it and pipe it to grep directly in the command line.

It comes much more natural to me than remembering what extensions do what and what type of regular expressions they support and so forth.

You didn't really state what your use case was, so if you are looking for specific information, this would be ideal for me, personally. If it is actually intended for searching for terms in online documentation or something, then no, this would not be the best answer.

rubynorails

Posted 2012-02-03T01:55:11.050

Reputation: 254

1

Fastest Search is the best text search on a page and in all tabs:

Count, regular expressions, visualize & list result/find-as-you-type.

There is an optional instant web and history search in the URL bar. It has the best custom search, multi-tab preview for selected text, dnd image/lnk, and autocopy.

diimdeep

Posted 2012-02-03T01:55:11.050

Reputation: 762

1

Checkout the Fastest Search Firefox Addon.

muralisc

Posted 2012-02-03T01:55:11.050

Reputation: 11